I'm trying to immitate web browser downloading some page, I have an array containing all components, and then use WWW::Mechanize to do downloading:
use WWW::Mechanize;
use Time::HiRes qw(time);
my $links=[
"http://web-page.to.download.to/",
"http://static.to.download.to/background.jpg",
"http://static.to.download.to/first.css",
"http://www.google-analytics.com/ga.js",
"http://static.ak.fbcdn.net/rsrc.php/v2/yl/r/6KM-54hh6R2.css",
];
my $start=time;
foreach (@$links) {
$mech->get($_);
};
my $stop=time;
This works more-or-less the way I intended, there are two problems though - since the list of links is dynamic, and partly created using javascript, I had to use the browser to create that list.
I need a way of parsing web page, and getting a list of all its component, and this is my first problem.
The other problem is that I'm serializing all downloading here - I should be using something more similiar to what browsers do - maybe use 4 concurrent downloaders?
How can I emulate 4 concurrent downloading threads?
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.