Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How can i have the titles and the prices?

by tobyink (Abbot)
on Sep 19, 2013 at 08:25 UTC ( #1054807=note: print w/ replies, xml ) Need Help??


in reply to How can i have the titles and the prices?

Don't parse HTML with regexps. Use an HTML parser.

#!/usr/bin/env perl use strict; use warnings; use HTML::HTML5::Parser; use XML::LibXML::QuerySelector; my $input = shift or die("Usage: $0 filename\n"); my $html = HTML::HTML5::Parser->load_html(location => $input); print $html->querySelector('h2.product-name a')->textContent, "\n"; print $html->querySelector('div.price-box span.price')->textContent, " +\n";

Output is:

Please help $20.00
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name


Comment on Re: How can i have the titles and the prices?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1054807]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (18)
As of 2014-07-14 13:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (260 votes), past polls