Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: From a given text Extract the root HTML element inner text

by marquezc329 (Scribe)
on Dec 06, 2012 at 18:02 UTC ( #1007631=note: print w/ replies, xml ) Need Help??


in reply to From a given text Extract the root HTML element inner text

Hello DEIVEEGARAJA, Multiple modules on CPAN are available for html parsing. You may find HTML::TokeParser to be useful. Example usage to print links from a page's source.

use HTML::TokeParser; my $p = HTML::TokeParser->new("webpage") or die "Can't open webpage: $!\n"; while (my $token = $p->get_tag('a')) { my $link =$token->[1]{href}; my $text = $p->get_trimmed_text('/a'); say "Link: $link"; say "Text: $text\n"; }

What have you already tried? Questions are better answered when supplemented with code.


Comment on Re: From a given text Extract the root HTML element inner text
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2015-07-29 01:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (260 votes), past polls