I wrote html/Javascript code a few years back to scrape financial data for the company I work for on Yahoo from inside the corporate firewall. It worked well. I didn't think it was pretty but did not know how to use code to access the page directly.

Now I want to re-write it using Perl, but from what sample code I could gather from the net, it always timed out. I figured it must be the firewall because if I replaced the url with a site internal to the firewall, the code works fine.

My question is....the page can be accessed from a browser (IE, Firefox, Chrome) which is using http protocol to bring the page in, so why can't Perl code do the same? I assume that Perl's library is also using the same protocol to do the work. How could the firewall distinguish that one is coming from a browser and one is something else? I tried to set the user-agent to Mozilla, and it still timed out.

I would appreciate your help on this. Is what I am trying to do possible?

The following is my code which is mostly copied from the net:

use strict; use LWP::Simple; use LWP::UserAgent; my $webpage = "http://www.google.com"; my $ua = LWP::UserAgent->new; $ua->agent("Mozilla/4.76 [en] (Windows NT 5.0; U)"); $ua->timeout(30); my $request = HTTP::Request->new('GET', $webpage); my $response = $ua->request($request); my $html = $response->content; print $html; exit(0);

In reply to Code To Get Pages by llao

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.