Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > 4ad3d1a5da4da0b6f17e448e62d8ca92 > files > 16

perl-Web-Scraper-0.370.0-3.mga4.noarch.rpm

#!/usr/bin/perl
use strict;
use warnings;
use lib "lib";
use URI;
use Web::Scraper;

# same as http://d.hatena.ne.jp/secondlife/20060922/1158923779

my $keyword = scraper {
    process 'span.title > a:first-child', title => 'TEXT', url => '@href';
    process 'span.furigana', furigana => 'TEXT';
    process 'ul.list-circle > li:first-child > a', category => 'TEXT';
};

my $res = $keyword->scrape(URI->new("http://d.hatena.ne.jp/keyword/%BA%B0%CC%EE%A4%A2%A4%B5%C8%FE"));

use YAML;
warn Dump $res;

__END__
---
category: アイドル
furigana: こんのあさみ
title: 紺野あさ美
url: /keyword/%ba%b0%cc%ee%a4%a2%a4%b5%c8%fe?kid=800