Just learning Perl. I am trying to create a script with LWP module that will grab the html/text from several web pages. Which I can get the info from one web page when I type it in using this;
use warnings; use LWP::UserAgent; my $UserAgent = new LWP::UserAgent; my $Request = new HTTP::Request ('get', 'www.website.com'); my $Response = $UserAgent->request ($Request); open (FILE, ">/strawberry/perl/file.txt"); print FILE $Response->{_content}; close (FILE);
Now I have also got the code that can take a file and treat it as an array and the entries in the file are the scalars. Maybe my description is off, but this script works.
use warnings; use strict; my $file = "/strawberry/perl/website.txt"; open (FH, "< $file") or die "Can't open $file for read: $!"; my @lines = <FH>; print @lines; close FH or die "Cannot close $file: $!";
Now I want to combine the two and make the 'get' to loop through every single entry on my website.txt file in the second code and record the information. Something like this;
my $Request= new HTTP::Request ('get','@lines')`or my $URL=get('@lines')
I have seen a lot of modules (and tutorials) that will will allow people to get info from web sites, but haven't seen anything on accessing multiple websites. I don't care what module I use really, just want to be able to access a large list of web sites that are in a text file. Any thought? Thanks in advance.

In reply to Web Scrapping" Using a List of Web Pages by nic12385

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.