- 论坛徽章:
- 1
|
本帖最后由 ziyunfei 于 2012-04-06 10:33 编辑
- use LWP::UserAgent;
- use URI::Escape;
- my $ua = LWP::UserAgent->new;
- my $html=$ua->get( "http://www.namejet.com/Pages/Downloads.aspx")->decoded_content;
- my ($VIEWSTATE) = $html =~ /(?<=_VIEWSTATE" value=")(.+?)(?=")/;
- my ($EVENTVALIDATION) = uri_escape($html =~ /(?<=__EVENTVALIDATION" value=")(.+?)(?=")/);
- while($html =~ /(?<=__doPostBack\(')(.+?)(?=',''\)">)/g){
- my $downloadid=$&;
- my $response=$ua->post( "http://www.namejet.com/Pages/Downloads.aspx",Content => "__EVENTTARGET=$downloadid&__VIEWSTATE=$VIEWSTATE&__EVENTVALIDATION=$EVENTVALIDATION");
- my ($downloadname) = $response->header("Content-disposition")=~/(?<=filename=)(.+)/;
- open FH, ">$downloadname";
- print FH $response->decoded_content;
- }
复制代码 |
|