root/Web-Scraper/trunk/eg/ebay-auction.pl

Revision 2239 (checked in by miyagawa, 13 years ago)

API CHANGE: Now scraper {} returns Web::Scraper object, not the closure.
You should call ->scrape() method to get the data back.

I loved the fact that it returns closure, but technically it doesn't
need to be, and this is actually more compatible with scrapi.rb and
less surprising to people.

  • Property svn:executable set to *
Line 
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use URI;
5 use lib "lib";
6 use Web::Scraper;
7
8 my $ebay_auction = scraper {
9     process "h3.ens>a",
10         description => 'TEXT',
11         url => '@href';
12     process "td.ebcPr>span", price => "TEXT";
13     process "div.ebPicture >a>img", image => '@src';
14     result 'description', 'url', 'price', 'image';
15 };
16
17 my $ebay = scraper {
18     process "table.ebItemlist tr.single",
19         "auctions[]" => $ebay_auction;
20     result 'auctions';
21 };
22
23 my $auctions = $ebay->scrape( URI->new("http://search.ebay.com/apple-ipod-nano_W0QQssPageNameZWLRS") );
24
25 use YAML;
26 warn Dump $auctions;
27
Note: See TracBrowser for help on using the browser.