Skip to content

Instantly share code, notes, and snippets.

@Cside
Created February 18, 2011 12:05
Show Gist options
  • Save Cside/833588 to your computer and use it in GitHub Desktop.
Save Cside/833588 to your computer and use it in GitHub Desktop.
はてブお気に入りパーサー
use URI;
use Web::Scraper;
sub scrape {
my ($class, $config) = @_;
my $url = "http://b.hatena.ne.jp/"
. $config->username
. "/favorite?threshold="
. $config->threshold;
my $scraper = scraper {
process "ul#bookmarked_user > li", 'entries[]' => scraper {
process "h3.entry > a.entry-link", title => "TEXT";
process "h3.entry > a.domain", domain => "TEXT";
process "ul > li.category > a.category-link", category => '@href';
process "div.comment > ul.comment > li.others > a.username", 'users[]' => 'TEXT';
};
};
my $res = $scraper->scrape(URI->new($url));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment