Hello,
I used LWP::UserAgent to retrieve HTML content of one page and it worked. All of a sudden same code does not work and I get error 503 instead. What might be wrong?
This is the page:
http://www.pubmedcentral.nih.gov/tocrender.fcgi?action=cited&tool=pubmed&pubmedid=17061271
And this is my code:
$pmc_string = "http://www.pubmedcentral.nih.gov/tocrender.fcgi?action=
+cited&tool=pubmed&pubmedid=17061271";
my $ua = LWP::UserAgent->new;
$ua->timeout(10);
$ua->env_proxy;
my $response = $ua->get($pmc_string,
'User-Agent' => 'Mozilla/5.0 [en] (Windows; U; Windows NT 6.0)',
'Accept' => 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, i
+mage/png, */*',
'Accept-Charset' => 'iso-8859-1,*,utf-8',
'Accept-Language' => 'en-US',
);
if ($response->is_success) {
print $response->content;
}
else {die $response->status_line;}
BTW, LWP::Simple does not work either. Same error 503.
Also, this external website is able to grab their HTML OK;
http://web-sniffer.net/?url=http%3A%2F%2Fwww.pubmedcentral.nih.gov%2Ftocrender.fcgi%3Faction%3Dcited%26tool%3Dpubmed%26pubmedid%3D17061271&submit=Submit&http=1.1&rawhtml=yes&type=GET&uak=0
What is wrong with my code?
Thanks!
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.