Retrieving web pages

Discussion in 'Perl Misc' started by Dackle, Dec 9, 2004.

  1. Dackle

    Dackle Guest

    Newbie question: I'm trying to retrieve general HTML web pages but
    running into a few problems, which in part are probably due to the
    fact that I've never used Perl modules before. I downloaded
    libwww-perl and copied LWP::Simple into the Perl lib directory, but
    I'm still having trouble grabbing web pages. I tried something like
    this:


    use LWP::Simple;
    $url="www.torontostar.com";
    $content= get($url);

    But I keep getting back a type 2 error saying File "internet" does
    not exist. I'm using the ActiveState port of Perl on Windows XP
    through the Crimson Editor. Any advice? Is there any other way to
    retrieve web pages using existing Perl modules?
     
    Dackle, Dec 9, 2004
    #1
    1. Advertising

  2. Dackle

    Henry Law Guest

    On 9 Dec 2004 10:30:22 -0800, (Dackle) wrote:

    >Newbie question: I'm trying to retrieve general HTML web pages but
    >running into a few problems, which in part are probably due to the
    >fact that I've never used Perl modules before. I downloaded
    >libwww-perl and copied LWP::Simple into the Perl lib directory, but
    >I'm still having trouble grabbing web pages. I tried something like
    >this:
    >


    use strict;
    use warnings; # Always - no help in this group otherwise!!
    >use LWP::Simple;
    >$url="www.torontostar.com";
    >$content= get($url);
    >
    > But I keep getting back a type 2 error saying File "internet" does
    >not exist. I'm using the ActiveState port of Perl on Windows XP
    >through the Crimson Editor. Any advice? Is there any other way to
    >retrieve web pages using existing Perl modules?


    I don't know what is going wrong on your system (file called
    "internet" doesn't sound right, somehow). But your problem is that
    you've left out the "http:". This works on my system (Activestate
    like yours); try it.

    # ------------START-------------
    use strict;
    use warnings;

    use LWP::Simple;
    my $url="http://www.torontostar.com";
    my $content= get($url);

    print substr($content,0,50),"\n";
    # --------------END-------------

    Output is:
    F:\$WIP>problem.pl
    <HTML>
    <HEAD>
    <script language="Javascript" src="h

    F:\$WIP>
    --

    Henry Law <>< Manchester, England
     
    Henry Law, Dec 9, 2004
    #2
    1. Advertising

  3. Dackle

    Dackle Guest

    OK, I'll give it a try. I think I used http:// in the URL and it didn't
    work, but I'll try use strict; and use warnings;.

    Henry Law wrote:
    > On 9 Dec 2004 10:30:22 -0800, (Dackle) wrote:
    >
    > >Newbie question: I'm trying to retrieve general HTML web pages but
    > >running into a few problems, which in part are probably due to the
    > >fact that I've never used Perl modules before. I downloaded
    > >libwww-perl and copied LWP::Simple into the Perl lib directory, but
    > >I'm still having trouble grabbing web pages. I tried something like
    > >this:
    > >

    >
    > use strict;
    > use warnings; # Always - no help in this group otherwise!!
    > >use LWP::Simple;
    > >$url="www.torontostar.com";
    > >$content= get($url);
    > >
    > > But I keep getting back a type 2 error saying File "internet"

    does
    > >not exist. I'm using the ActiveState port of Perl on Windows XP
    > >through the Crimson Editor. Any advice? Is there any other way to
    > >retrieve web pages using existing Perl modules?

    >
    > I don't know what is going wrong on your system (file called
    > "internet" doesn't sound right, somehow). But your problem is that
    > you've left out the "http:". This works on my system (Activestate
    > like yours); try it.
    >
    > # ------------START-------------
    > use strict;
    > use warnings;
    >
    > use LWP::Simple;
    > my $url="http://www.torontostar.com";
    > my $content= get($url);
    >
    > print substr($content,0,50),"\n";
    > # --------------END-------------
    >
    > Output is:
    > F:\$WIP>problem.pl
    > <HTML>
    > <HEAD>
    > <script language="Javascript" src="h
    >
    > F:\$WIP>
    > --
    >
    > Henry Law <>< Manchester, England
     
    Dackle, Dec 9, 2004
    #3
  4. Dackle

    Henry Law Guest

    On 9 Dec 2004 11:00:28 -0800, "Dackle" <> wrote:

    >OK, I'll give it a try. I think I used http:// in the URL and it didn't
    >work, but I'll try use strict; and use warnings;.


    It's not a matter of "trying" ... putting them in makes it easier to
    find some kinds of problem and since nobody writes perfect code first
    time you should always use them.

    Sorry to sound like a school teacher here but I'm trying to help ...
    Saying that something "doesn't work" doesn't help people to help you.
    Much better to say what you expected it to do and what it actually
    did. Anyway, unless there's a bug in perl itself then the code you
    write always "works", in the sense that it does what it does. The
    problem comes when what it does is not what you thought it would do.

    >> On 9 Dec 2004 10:30:22 -0800, (Dackle) wrote:


    >> > But I keep getting back a type 2 error saying File "internet"

    >does
    >> >not exist.


    I meant to advise you earlier: it's much better to copy and paste
    error messages, rather than giving a general description of them as
    you have done above. The exact text is sometimes important.

    Lastly, please don't top post; it's against the agreed guidelines for
    this group. In addition many people hate it with a passion and most
    of them are the ones you need to help you.
    --

    Henry Law <>< Manchester, England
     
    Henry Law, Dec 9, 2004
    #4
  5. Dackle wrote:

    > fact that I've never used Perl modules before. I downloaded
    > libwww-perl and copied LWP::Simple into the Perl lib directory


    That's the first problem. Read and follow the instructions in 'perldoc
    perlmodinstall' - don't just copy files around.

    > I'm still having trouble grabbing web pages. I tried something like
    > this:


    Post the code you tried, not "something like" it. Copy and paste it,
    don't try to re-type it.

    Have you read the posting guidelines that appear here frequently?

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
     
    Sherm Pendley, Dec 9, 2004
    #5
  6. Dackle

    Tintin Guest

    "Dackle" <> wrote in message
    news:...
    > Newbie question: I'm trying to retrieve general HTML web pages but
    > running into a few problems, which in part are probably due to the
    > fact that I've never used Perl modules before. I downloaded
    > libwww-perl and copied LWP::Simple into the Perl lib directory.


    You can't just randomly copy parts of Perl modules and hope they will work.

    ActiveState Perl uses PPM to manage Perl modules. Either type 'ppm' at the
    command line, or follow:

    Start->Programs->ActiveState Perl->Perl Package Manager

    Anyway, you don't need to install libwww as it comes standard with
    ActiveState Perl.
     
    Tintin, Dec 10, 2004
    #6
  7. Dackle

    Anno Siegel Guest

    Tintin <> wrote in comp.lang.perl.misc:
    >
    > "Dackle" <> wrote in message
    > news:...
    > > Newbie question: I'm trying to retrieve general HTML web pages but
    > > running into a few problems, which in part are probably due to the
    > > fact that I've never used Perl modules before. I downloaded
    > > libwww-perl and copied LWP::Simple into the Perl lib directory.

    >
    > You can't just randomly copy parts of Perl modules and hope they will work.


    You can always hope!

    Anno
     
    Anno Siegel, Dec 10, 2004
    #7
  8. Dackle

    Dackle Guest

    Thanks, I've got it running now. The error was in fact caused by
    the filename in the text editor and not Perl itself. Sorry for the
    confusion and the sloppiness.
     
    Dackle, Dec 10, 2004
    #8
  9. Dackle

    VBSome Guest

    If all you are trying to do is navigate some web pages and look at the
    results then I would suggest you use WWW::Mechanize or if on a Win32
    platform Win32::IE::Mechanize (which is the same module as the first one but
    uses IE as a browser). These 2 modules are much easier to use then LWP.




    "Dackle" <> wrote in message
    news:...
    > Newbie question: I'm trying to retrieve general HTML web pages but
    > running into a few problems, which in part are probably due to the
    > fact that I've never used Perl modules before. I downloaded
    > libwww-perl and copied LWP::Simple into the Perl lib directory, but
    > I'm still having trouble grabbing web pages. I tried something like
    > this:
    >
    >
    > use LWP::Simple;
    > $url="www.torontostar.com";
    > $content= get($url);
    >
    > But I keep getting back a type 2 error saying File "internet" does
    > not exist. I'm using the ActiveState port of Perl on Windows XP
    > through the Crimson Editor. Any advice? Is there any other way to
    > retrieve web pages using existing Perl modules?
     
    VBSome, Dec 10, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric

    retrieving https pages

    Eric, Jul 19, 2005, in forum: Python
    Replies:
    2
    Views:
    351
    Mike Meyer
    Jul 20, 2005
  2. Nathan Sokalski
    Replies:
    5
    Views:
    1,083
    Gaurav Vaish \(www.Edujini-Labs.com\)
    Jan 10, 2007
  3. Giggi
    Replies:
    4
    Views:
    298
    Giggi
    Jan 4, 2007
  4. Nathan Sokalski
    Replies:
    4
    Views:
    341
    Nathan Sokalski
    Dec 21, 2006
  5. Nathan Sokalski
    Replies:
    4
    Views:
    378
    Nathan Sokalski
    Dec 21, 2006
Loading...

Share This Page