Hi!
I am new here so pardon me for my naivity! I have written this code for grabbing the text(only the text) for a URL(e.g www.msn.com) with Perl:
[CODE=perl] use LWP:: UserAgent;
use HTTP::Request;
sub get_url{
my $url=shift;
my $ua=new LWP::UserAgent;
my $req=new HTTP::Request 'GET',$url;
$ua ->timeout(10);
my src = $ua ->request($req );
return $src->content unless (!$src ->is_success);
return 0; }
sub dehtml{
my $src=shift;
$src=~ s/<.*?>//g;
$scr=~ s/<[^>]*>//g;
print $src. }
dehtml(get_url( http://www.msn.com/)); [/CODE]
It works pretty well.
How can I also grab the text(only the text) of the links that URL(www.msn.com) has?
Thank u in advance for any help! :)
I am new here so pardon me for my naivity! I have written this code for grabbing the text(only the text) for a URL(e.g www.msn.com) with Perl:
[CODE=perl] use LWP:: UserAgent;
use HTTP::Request;
sub get_url{
my $url=shift;
my $ua=new LWP::UserAgent;
my $req=new HTTP::Request 'GET',$url;
$ua ->timeout(10);
my src = $ua ->request($req );
return $src->content unless (!$src ->is_success);
return 0; }
sub dehtml{
my $src=shift;
$src=~ s/<.*?>//g;
$scr=~ s/<[^>]*>//g;
print $src. }
dehtml(get_url( http://www.msn.com/)); [/CODE]
It works pretty well.
How can I also grab the text(only the text) of the links that URL(www.msn.com) has?
Thank u in advance for any help! :)
Comment