Perl Help!!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • orfeas
    New Member
    • Mar 2006
    • 2

    #1

    Perl Help!!!

    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! :)
    Last edited by eWish; Nov 18 '07, 02:36 AM. Reason: Added Code Tags
  • eWish
    Recognized Expert Contributor
    • Jul 2007
    • 973

    #2
    Search CPAN for an HTML Parser. This is easily done with a module.

    --Kevin

    Comment

    Working...