Loading ...
Sorry, an error occurred while loading the content.

Re: How do I process a webpage

Expand Messages
  • daymobrew@yahoo.com
    I m going to describe how to get a page from a web site. Apologies if this is not the part you are stuck on. #!/usr/local/bin/perl -w use strict; use
    Message 1 of 2 , Feb 1 4:51 PM
    • 0 Attachment
      I'm going to describe how to get a page from a web site. Apologies if
      this is not the part you are stuck on.

      #!/usr/local/bin/perl -w

      use strict;
      use LWP::UserAgent;
      use HTTP::Request;

      my ( $ua, $request, $response );

      $ua = LWP::UserAgent->new;

      $request = HTTP::Request->new( GET => 'http://www.d.com/index.html' );
      $response = $ua->request( $request );

      # Display the returned data.
      print "Content:\n" . $response->content if ( $response->code == 200
      );

      # This crude code removes the HTML tags, leaving the basic text.
      # my $HTMLContent = $response->content;
      # $HTMLContent =~ s/<.*?>//g;
      # print "\n\n$HTMLContent";
      __END__

      This is a very simple example. You can assign the returned content
      ($response->content) to a variable (like in the commented out code at
      the end) and then parse it as you need.

      Damien.

      --- In perl-beginner@y..., slavik944@m... wrote:
      > Hello once again all, I have been assigned a project at work that
      > requires the following.
      > Access a webpage and gather the data from it. From what I
      > understaned
      > the program that I will be creating will access the webpage in
      > question via conventional methods. In other words, I dont ftp to
      the
      > server and download the page itself. I have to access it via a web
      > browser.
      > So the reason I'm contacting this list is to ask to be pointed in
      the
      > right direction as to where I should look to do this. Also, if
      > anyone
      > has any useful input regarding this matter I would like to hear it.
      >
      > Thanks,
      > Steve M
    Your message has been successfully submitted and would be delivered to recipients shortly.