Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: Does anyone have experience with Reddit::Client?

by kroach (Pilgrim)
on Feb 15, 2015 at 21:18 UTC ( [id://1116818]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Does anyone have experience with Reddit::Client?
in thread Does anyone have experience with Reddit::Client?

Yes, there is. One way is to remember the id of the last post in a chunk and pass it as the 'after' parameter to fetch_links(). Here is an example fetching post titles in chunks of size 25 (though, any size up to 100 will, of course, work):

use strict; use warnings; use feature 'say'; use Reddit::Client; my $subreddit = '/r/perl'; my $limit = 25; my $reddit = Reddit::Client->new(user_agent => 'MyApp/1.0'); my $last_post; foreach my $page (1 .. 8) { my $links = $reddit->fetch_links( subreddit => $subreddit, limit => $limit, after => $last_post ); foreach my $link (@{ $links->{items} }) { say $page, ': ', $link->{title}; } $last_post = $links->{items}->[-1]->{name}; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1116818]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-23 17:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found