forked from miyagawa/web-scraper
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix content decoding and add a unit test for this issue
- Loading branch information
Andrew Whatson
committed
Feb 4, 2010
1 parent
fad055a
commit ea24deb
Showing
2 changed files
with
33 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
use strict; | ||
use warnings; | ||
use URI; | ||
use LWP::UserAgent; | ||
use Web::Scraper; | ||
use Test::More; | ||
|
||
plan skip_all => "LIVE_TEST not enabled" | ||
unless $ENV{LIVE_TEST} || $ENV{TEST_ALL}; | ||
|
||
plan tests => 2; | ||
|
||
my $ua = LWP::UserAgent->new; | ||
$ua->default_header('Accept-Encoding' => 'gzip'); | ||
{ | ||
my $res = $ua->get("http://www.yahoo.co.jp/"); | ||
my $result = scraper { | ||
process 'title', title => 'TEXT'; | ||
}->scrape($res); | ||
is $result->{title}, 'Yahoo! JAPAN'; | ||
} | ||
|
||
{ | ||
my $res = $ua->get("http://b.hatena.ne.jp/"); | ||
my $result = scraper { | ||
process 'img.csschanger', image => '@src'; | ||
}->scrape($res); | ||
is $result->{image}, 'http://b.hatena.ne.jp/images/logo1.gif', 'Absolute URI'; | ||
} | ||
|
||
|
||
|