Hi
i'm creating a small perl program in order to get the html source from pages in order to check them.
i wrote this:
#!/usr/local/bin/perl
use HTTP::Cookies;
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$ua->cookie_jar(HTTP::Cookies->new(file => "cookies.txt", autosave => 1));
#$ua->agent("Mozilla 5.0");
$url=" site address";
$v1="2014-03-02";
$v2="2014-03-03";
$req = HTTP::Request->new(GET => $url, $checkin => $v1, $checkout => $v2);
$req->header('Accept' => 'text/html');
$res = $ua->request($req);
if ($res->is_success)
{
$filename="dati_html_test.txt";
open MYFILE, ">:utf8", $filename;
print MYFILE $res->decoded_content; # or whatever
close (MYFILE);
}
else
{
print "Error: " . $res->status_line . "\n";
}
The problem i have are those:
1) it seems that the website thinks that i'm a bot: i'm unable to set a proprer user agent
2) it seems that the url parameters are not understood by the webserver because it always answer me with a html page like i didn't submit any parameter.
any help?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.