芸能ランキングからTOP10のリンクとタイトルだけスクレイピング
いくつかfeed購読している芸能ネタの芸能人 | エンターテインメント - 人気ブログランキングから
- TOP10のリンク先タイトル
- TOP10のリンク先URL
を取得。
リンク先textのタグ全体は
process '//tr[@class="d1"]/td[@class="d2"]/a[@class="best10"]'
リンク先textのリンク先URLは
'link[]' => '@href'
'title[]' => 'TEXT'
全体はこんな感じになりました。
scraper.pl
#!/usr/local/bin/perl use strict; use Web:craper; use URI; my $uri = URI->new("http://blog.with2.net/rank1110-0.html"); my $scraper = scraper { process '//tr[@class="d1"]/td[@class="d2"]/a[@class="best10"]',ink[]' => '@href','title[]' => 'TEXT'; }; my $result = $scraper->scrape($uri);
実行結果
--- link: - !!perl/scalar:URI::http http://blog.with2.net/out.php?162153;http%3A%2F%2Fameblo.jp%2Furaurageinou%2F - !!perl/scalar:URI::http http://blog.with2.net/out.php?535599;http%3A%2F%2Fkeywordjiten.seesaa.net%2F - !!perl/scalar:URI::http http://blog.with2.net/out.php?556664;http%3A%2F%2Fhohohoi01.blog41.fc2.com%2F - !!perl/scalar:URI::http http://blog.with2.net/out.php?586528;http%3A%2F%2Fwww.les2.net%2F - !!perl/scalar:URI::http http://blog.with2.net/out.php?476416;http%3A%2F%2Fsatadosensu.blog84.fc2.com%2F title: - ズバリ!裏芸能 - 芸能界の裏の顔 - 裏芸能画像でスーパーリフレッシュ〜!! - レッツ芸能ニュース - 話題沸騰!う・わ・さのお宝画像