Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can anyone tell me how to parse HTML for anchor tag info

Status
Not open for further replies.

JustShaun

Programmer
Oct 1, 2003
1
US
Hello can anyone tell me how i would go about parsing HTML from a url to gather anchor tags content?
 
HTML::TreeBuilder inherits the methods of both HTML::parser and HTML::Element. The methods inherited from HTML::parser are used for building the HTML tree, and the methods inherited from HTML::Element are what you use to scrutinize the tree.

Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884

It's like this; even samurai have teddy bears, and even teddy bears get drunk.
 
You can do it pretty quickly by hand too. Something like:

#!/usr/local/bin/perl

use LWP::Simple;
use strict;
my $content = &get("
my @urls = $content =~ /href="(.*?)"/smig;

print join("\n", @urls), "\n";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top