root/Web-Scraper/trunk/eg/extract-links.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 $uri = shift @ARGV or die "URI needed";
9
10 my $scraper = scraper {
11     process "a[href]", "urls[]" => '@href';
12     result 'urls';
13 };
14
15 my $links = $scraper->scrape(URI->new($uri));
16 use YAML;
17 warn Dump $links;
18
Note: See TracBrowser for help on using the browser.