Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2003
    Posts
    2

    Unhappy Unanswered: LWP not work when I get a webpage!

    Hi everyone,
    I would like to using the get command in perl script to get a webpage, for example http://www.google.com/ so that I can parse this result in my script. I also installed libwww-perl-5.69 and libnet-1.16 but they didn't work. The problem is not right with the links and I think it takes in the configuration when setting up libnet or what should I set before I run this script? My script likes this:


    #!/usr/bin/perl -w
    use strict;
    use LWP:imple;

    my $content = get("http://www.google.com/");
    print $content;

    if (is_success(getprint("http://www.google.com/"))) {
    print "Connect successed!";
    }

    And this is the result:

    Use of uninitialized value in pattern match (m//) at :/Perl!/site/lib/LWP/Protocol.pm line 114.
    Use of uninitialized value in concatenation (.) or string at C:/Perl!/site/lib/LWP/Protocol.pm line 87.
    Use of uninitialized value in print at a.pl line 6.
    Use of uninitialized value in pattern match (m//) at C:/Perl!/site/lib/LWP/Protocol.pm line 114.
    Use of uninitialized value in concatenation (.) or string at C:/Perl!/site/lib/LWP/Protocol.pm line 87.
    501 Protocol scheme '' is not supported <URL:http://www.google.com/>


    Thanks advance for anyone who help me solve in this case!
    Best regards,

  2. #2
    Join Date
    Sep 2003
    Location
    Montreal, Qc
    Posts
    1

    Re: LWP not work when I get a webpage!

    your pattern matching depends on the content returned don't forget that sometimes in HTML there are characters that are added to a page such as $ @ and others that might affect your variables in a weird way and cause concatenation errors. Anyways i tried on and it worked for me today but depending on the content it might not, you have to catch these errors.

  3. #3
    Join Date
    Jun 2004
    Location
    Nowhere Near You
    Posts
    89

    It works for me ...

    Code:
    C:\Code\hacks>perl -d test.pl
    Default die handler restored.
    
    Loading DB routines from perl5db.pl version 1.07
    Editor support available.
    
    Enter h or `h h' for help, or `perldoc perldebug' for more help.
    
    main::(test.pl:5):      my $content = get("http://www.google.com/");
      DB<1> r
    <html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title><style><!--
    body,td,a,p,.h{font-family:arial,sans-serif;}
    .h{font-size: 20px;}
    .q{color:#0000cc;}
    //-->
    </style>
    <script>
    <!--
    function sf(){document.f.q.focus();}
    // -->
    </script>
    </head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onLoad=sf()><center><table border=0 cellspacing=0
     cellpadding=0><tr><td><img src="/images/logo.gif" width=276 height=110 alt="Google"></td></tr></table><br>
    <form action="/search" name=f><table border=0 cellspacing=0 cellpadding=4><tr><td nowrap class=q><font size=-1><b><font color=#00000
    0>Web</font></b>&nbsp;&nbsp;&nbsp;&nbsp;<a id=1a class=q href="/imghp?hl=en&tab=wi&ie=UTF-8">Images</a>&nbsp;&nbsp;&nbsp;&nbsp;<a id
    =2a class=q href="/grphp?hl=en&tab=wg&ie=UTF-8">Groups</a>&nbsp;&nbsp;&nbsp;&nbsp;<a id=4a class=q href="/nwshp?hl=en&tab=wn&ie=UTF-
    8">News</a>&nbsp;&nbsp;&nbsp;&nbsp;<a id=5a class=q href="/froogle?hl=en&tab=wf&ie=UTF-8">Froogle</a>&nbsp;&nbsp;&nbsp;&nbsp;<b><a h
    ref="/options/index.html" class=q>more&nbsp;&raquo;</a></b></font></td></tr></table>  <table cellspacing=0 cellpadding=0><tr><td wid
    th=25%>&nbsp;</td><td align=center><input type=hidden name=hl value=en><span id=hf></span><input type=hidden name=ie value="ISO-8859
    -1"><input maxLength=256 size=55 name=q value=""><br><input type=submit value="Google Search" name=btnG><input type=submit value="I'
    m Feeling Lucky" name=btnI></td><td valign=top nowrap width=25%><font size=-2>&nbsp;&nbsp;<a href=/advanced_search?hl=en>Advanced&nb
    sp;Search</a><br>&nbsp;&nbsp;<a href=/preferences?hl=en>Preferences</a><br>&nbsp;&nbsp;<a href=/language_tools?hl=en>Language Tools<
    /a></font></td></tr></table></form><br><br><font size=-1><a href="/ads/">Advertising&nbsp;Programs</a> - <a href="/services/">Busine
    ss&nbsp;Solutions</a> - <a href=/about.html>About Google</a></font><p><font size=-2>&copy;2004 Google - Searching 4,285,199,774 web
    pages</font></p></center></body></html><html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Go
    ogle</title><style><!--
    body,td,a,p,.h{font-family:arial,sans-serif;}
    .h{font-size: 20px;}
    .q{color:#0000cc;}
    //-->
    </style>
    <script>
    <!--
    function sf(){document.f.q.focus();}
    // -->
    </script>
    </head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onLoad=sf()><center><table border=0 cellspacing=0
     cellpadding=0><tr><td><img src="/images/logo.gif" width=276 height=110 alt="Google"></td></tr></table><br>
    <form action="/search" name=f><table border=0 cellspacing=0 cellpadding=4><tr><td nowrap class=q><font size=-1><b><font color=#00000
    0>Web</font></b>&nbsp;&nbsp;&nbsp;&nbsp;<a id=1a class=q href="/imghp?hl=en&tab=wi&ie=UTF-8">Images</a>&nbsp;&nbsp;&nbsp;&nbsp;<a id
    =2a class=q href="/grphp?hl=en&tab=wg&ie=UTF-8">Groups</a>&nbsp;&nbsp;&nbsp;&nbsp;<a id=4a class=q href="/nwshp?hl=en&tab=wn&ie=UTF-
    8">News</a>&nbsp;&nbsp;&nbsp;&nbsp;<a id=5a class=q href="/froogle?hl=en&tab=wf&ie=UTF-8">Froogle</a>&nbsp;&nbsp;&nbsp;&nbsp;<b><a h
    ref="/options/index.html" class=q>more&nbsp;&raquo;</a></b></font></td></tr></table>  <table cellspacing=0 cellpadding=0><tr><td wid
    th=25%>&nbsp;</td><td align=center><input type=hidden name=hl value=en><span id=hf></span><input type=hidden name=ie value="ISO-8859
    -1"><input maxLength=256 size=55 name=q value=""><br><input type=submit value="Google Search" name=btnG><input type=submit value="I'
    m Feeling Lucky" name=btnI></td><td valign=top nowrap width=25%><font size=-2>&nbsp;&nbsp;<a href=/advanced_search?hl=en>Advanced&nb
    sp;Search</a><br>&nbsp;&nbsp;<a href=/preferences?hl=en>Preferences</a><br>&nbsp;&nbsp;<a href=/language_tools?hl=en>Language Tools<
    /a></font></td></tr></table></form><br><br><font size=-1><a href="/ads/">Advertising&nbsp;Programs</a> - <a href="/services/">Busine
    ss&nbsp;Solutions</a> - <a href=/about.html>About Google</a></font><p><font size=-2>&copy;2004 Google - Searching 4,285,199,774 web
    pages</font></p></center></body></html>Connect successed!Debugged program terminated.  Use q to quit or R to restart,
      use O inhibit_exit to avoid stopping after program termination,
      h q, h R or h O to get additional info.
      DB<1> q
    
    C:\Code\hacks>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •