avinashbot / redd

Redd is a batteries-included API wrapper for reddit.
MIT License
186 stars 75 forks source link

Next page #83

Open ghost opened 6 years ago

ghost commented 6 years ago

hey, I saw your post on the repos reddit page. I tired the example code you commented but I got some weird error that the second page variable is not found. I checked the repo to see if you created a function to get more pages, I did not see one. Its pretty late right now and im tired so I prob missed it or its a dumb fix.

My code is:

    num = rand(1...100)
    r_all = reddit.subreddit("snapfuck")
    post = r_all.top(time: :all, after: second_page.after)
    post_url = post.url
    check_url = post_url.split(".").last
    puts check_url, post_url

My code before I attempted to edit it was, there was a big list of certain subreddits and it would pick one by random and then scrape a random image from that page.

subredit =  [ 'sample7', 'sample6', 'sample5', 'sample4', 'sample3', 'sample2', 'sample1'].sample
num = rand(1...100)
r_all = reddit.subreddit(subreddits)
post = r_all.hot[num]
post = r_all.top(time: :all, after: second_page.after)
post_url = post.url
check_url = post_url.split(".").last
puts check_url, post_url

its prob an easy fix, but i cant figure it out. prob been working on it to long and got tunnel vision.