CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner: Re: [Zhris] Perl Documentation: Edit Log

New User

Feb 19, 2013, 1:50 PM

Views: 1082
Re: [Zhris] Perl Documentation

Thank you for your response.

This is pretty much my very beginnings of Perl use, and have gone with bare minimums for a deeper understanding of Perl for most of my project, but this project really needs the depth of css selector syntax to do right so I am planning on sticking with Web::Scrapper.

I still do not understand why the syntax of this package is this way but have experimented and read enough examples to get a far better understanding of at least some of what you can do with it. It is worth mentioning that you can nest these "process"es. So for example if you are scraping a table, you can do:

my $web_scraper = scraper { 
process 'body>', table => scraper { #the .data is if the table has a class called data
process '>thead>tr>th', 'header[]' => 'TEXT';
process '>tbody>tr', 'rows[]' => scraper {
process '>td', 'cols[]' => 'TEXT';
process '>td>a', link => '@href';

This will produce a two dimensional array style data structure, with the header text stored alongside and this example even captures some link that each row has. You would access this like:

my $data = $web_scraper->scrape(''); 

(This post was edited by wisnoskij on Feb 19, 2013, 2:08 PM)

Edit Log:
Post edited by wisnoskij (New User) on Feb 19, 2013, 2:08 PM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives