Skip to content

Instantly share code, notes, and snippets.

@cherenkov

cherenkov/output Secret

Forked from anonymous/test.pl
Created April 14, 2012 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cherenkov/af4ec2c95b06bd09792b to your computer and use it in GitHub Desktop.
Save cherenkov/af4ec2c95b06bd09792b to your computer and use it in GitHub Desktop.
はてな用
$VAR1 = {
'td' => [
'青眼の白龍',
'ブルーアイズ・ホワイト・ドラゴン'
]
};
#PERLのスクレイピングに関しての質問です。 Web::Scraperを使用.. - 人力検索はてな
#http://q.hatena.ne.jp/1334296420
#参考
#Web::Scraper 勝手に添削 - Bulknews::Subtech - subtech
#http://subtech.g.hatena.ne.jp/miyagawa/20070510/1178794595
#
#Web::Scraper使ってみた - Unknown::Programming
#http://d.hatena.ne.jp/fbis/20070510/1178783909
#!"C:\xampp\perl\bin\perl.exe"
print "Content-type: text/html; charset=UTF-8\n\n";
use strict;
use warnings;
use Web::Scraper;
use Data::Dumper;
use Encode;
use URI;
my $url = URI->new('http://yugioh.wikia.com/wiki/Blue-Eyes_White_Dragon');
my $res = scraper {
process '//td[preceding-sibling::th[contains(text(),"Japanese")]]/span', 'td[]' => sub {
my $text = $_->as_text or return;
$text = encode('utf-8', $text);
return $text;
};
}->scrape($url);
print Dumper $res;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment