Skip Menu |

This queue is for tickets about the WWW-Mechanize-Plugin-Web-Scraper CPAN distribution.

Report information
The Basics
Id: 77219
Status: new
Priority: 0/
Queue: WWW-Mechanize-Plugin-Web-Scraper

People
Owner: Nobody in particular
Requestors: michael.jemmeson [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Handle multiple process commands within scraper block
Web::Scraper allows multiple 'process' commands within a scraper block, e.g. my $scraper = scraper { process '//ol/li', 'items[]' => '@id'; process '//div[@id="navigation"]/a[. = "next"]', next => '@href'; }; (which gives { items => [], next => '...' }) It would be nice if WWW::Mechanize::Plugin::Web::Scraper could support this, with something like the following: sub scrape { my ( $mech, @processes ) = @_; unless ( ref $processes[0] && ref $processes[0] eq 'ARRAY' ) { @processes = ( [@processes] ); } my $scraper = scraper { process @{$_} foreach @processes }; return $scraper->scrape( $mech->response ); } which would allow either the single array (as the current behaviour), or an array of arrayrefs. For example the above code would become: $mech->scrape( [ '//ol/li', 'items[]' => '@id' ], [ '//div[@id="navigation"]/a[. = "next"]', next => '@href' ], ); (Thanks for the module anyway - very helpful!)