I'm trying to pull URLs off of a website, but accessing this website with WWW::Mechanize is extremely slow - on the order of 3-5 mins(!). However, with my browser, the page is accessed virtually instantaneously.
Once I get the page contents, the rest of my script (not reproduced) quickly executes, so I know the problem is somewhere in the get.
I've produced a sample code below that simply prints the response object (after the substantial delay):
use strict;
use warnings;
use WWW::Mechanize;
my $request = WWW::Mechanize->new;
$request->agent_alias('Windows Mozilla');
my $response = $request->get( 'https://ai.fmcsa.dot.gov/SMS/Tools/Down
+loads.aspx' );
print "Got Website:\n\n$response\n";
As you can see from the code, I've tried different agent aliases, but from experimenting, that doesn't change anything.
Originally, I was thinking it was a problem with ASPX pages, but I can't find any pattern to the behavior. For example, https://www.google.com is quickly "got". However, https://demos.devexpress.com/ASPxNavigationAndLayoutDemos/TabControl/Templates.aspx, a random aspx site I found on Google is also accessed slowly. But then https://msdn.microsoft.com/en-us/library/2wawkw1c.aspx is accessed about as fast as google.com.
Is there any kind of verbose/debug output I can set on WWW::Mechanize to get a sense of what's causing it to be so slow? I'm guessing it's hanging on something, and only completing after timing out, but I have no idea what that could be, or how to fix it--if it's fixable--from my end.
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.