Jump to content
UBot Underground

Scraping Reddit Subreddit Subjects


Recommended Posts

I'm just working to figure out ubot. I was curious if someone could explain how to scrape every subject from a subreddit in reddit, and then go to the next page and do the same thing. This is without knowing what the subject text says in advanced.

 

Sorry if this seems very easy, but like I said... new. 

 

Ideally, I would like every subject to be added to a list.

 

I am on a dev license btw.

Edited by jisaacs1207
Link to post
Share on other sites

Heres a simple enough example at the bottom,I had a problem clicking next,so I scraped the href and navigate to it

 

At the top Ive added for using http get which is much faster for scraping,as you can see from the code,it is very similar to the below code,the plugin is available on a thread I started

define scrapeSubReddits(#subReddit) {
    plugin command("SocketCommands.dll", "socket container") {
        plugin command("SocketCommands.dll", "socket navigate", "GET", "https://www.reddit.com/r/{#subReddit}/")
        add list to list(%titles,$plugin function("DeliterCSS.dll", "Deliter CSS Selector", $plugin function("SocketCommands.dll", "$socket page html"), ".title.may-blank ", "TextContent"),"Delete","Global")
        loop while($comparison($plugin function("DeliterCSS.dll", "Easy HTML Parser", $plugin function("SocketCommands.dll", "$socket page html"), "a", "rel", "= (Attribute equals example \'class = myclass\')", "nofollow next", "href"),">",$nothing)) {
            set(#scrapePageLink,$plugin function("DeliterCSS.dll", "Easy HTML Parser", $plugin function("SocketCommands.dll", "$socket page html"), "a", "rel", "= (Attribute equals example \'class = myclass\')", "nofollow next", "href"),"Local")
            plugin command("SocketCommands.dll", "socket navigate", "GET", #scrapePageLink)
         
            add list to list(%titles,$plugin function("DeliterCSS.dll", "Deliter CSS Selector", $plugin function("SocketCommands.dll", "$socket page html"), ".title.may-blank ", "TextContent"),"Delete","Global")
        }
    }
}
scrapeSubReddits("LifeProTips")

define scrapeSubReddits(#subReddit) {
    navigate("https://www.reddit.com/r/{#subReddit}/","Wait")
    wait for browser event("Everything Loaded","")
    add list to list(%titles,$scrape attribute(<class="title may-blank ">,"innertext"),"Delete","Global")
    loop while($exists(<rel="nofollow next">)) {
        set(#scrapePageLink,$scrape attribute(<(tagname="a" AND rel="nofollow next")>,"href"),"Local")
        navigate(#scrapePageLink,"Wait")
        wait for browser event("Everything Loaded","")
        add list to list(%titles,$scrape attribute(<class="title may-blank ">,"innertext"),"Delete","Global")
    }
}
scrapeSubReddits("LifeProTips")

Link to post
Share on other sites
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...