Why am I getting an Internal Server error while using Mechanize to do the file fetching?
I'm having trouble downloading an mp4 file using WWW::Mechanize. A normal browser, like Firefox, can do the file fetching without any problem with or without Javascript enabled. So it seems to me Javascript, the usual suspect, hasn't played a real part in my problem. I've also added in my script the same headers as sent by Firefox to the file server when doing the fetch so that the server may see Mechanize as a normal browser, but the problem persists. And Win32::IE::Mechanize can also do the job well but why Mechanize can't?
Any ideas? Thanks in advance :)
Here's a my script:
use strict;
use warnings;
use WWW::Mechanize;
my $browser = WWW::Mechanize->new();
$browser->cookie_jar(HTTP::Cookies->new());
$browser->add_header('User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.1.11) Gecko/20100701 Firefox/3.5.11');
$browser->add_header('Accept' => 'text/xml,application/xml,application/xhtml+xml;q=0.9,*/*;q=0.8');
$browser->add_header('Accept-Language' => 'zh-cn,zh;q=0.5');
$browser->add_header('Accept-Encoding' => 'gzip,deflate');
$browser->add_header('Accept-Charset' => 'GB2312,utf-8;q=0.7,*;q=0.7');
$browser->add_header('Keep-Alive' => 300);
$browser->add_header('Connection' => 'keep-alive');
my $url = 'http://119.167.217.206:19765/ppvaplaybyopen?url=http://119.167.217.206/%d3%e9%c0%d6%b0%d9%b7%d6%b0%d9-100803-%d0%a1%d6%ed%bd%dc%c2%d7%b7%d6%d7%e9%d0%e3%c7%f2%bc%bc.mp4/segno=0%26&rid=A8F1F5DFEB1B11F1D90B40AD1BB75D69&filelength=21293994&blocksize=2097152&blocknum=11&blockmd5=E210862B3F92935D0883E00AA2A38F08@D793599727C6DA4ACDB1CBF2235004AC@D5E9C9245C9A1BB63BC5EDA862A32604@51B5FDF91356B2B4E943EF72648EB0AD@6F2400488B04EBF66A60336B795EA142@8E51B8DCF87A7A02B84A2CAA5FFCA3CF@89080D683268481694DBA6D1E22A2EFF@8F56225C76854A434385A09C319BF9C3@9AB0A3F199183F479F8887D1C3341B1B@845FE0D711086CC2D086546CD26B35C1@9D93A9BE1D2EDE216AA9EBF26BF414BE';
$browser->get($url);
I'm receiving the following error message:
Error GETing http://119.167.217.206:19765/ppvaplaybyopen?url=http://119.167.217.206/%d3%e9%c0%d6%b0%d9%b7%d6%b0%d9-100803-%d0%a1%d6%ed%bd%dc%c2%d7%b7%d6%d7%e9%d
0%e3%c7%f2%bc%bc.mp4/segno=0%26&rid=A8F1F5DFEB1B11F1D90B40AD1BB75D69&filelength=21293994&blocksize=2097152&blocknum=11&blockmd5=E210862B3F92935D0883E00AA2A38F08
@D793599727C6DA4ACDB1CBF2235004AC@开发者_运维知识库D5E9C9245C9A1BB63BC5EDA862A32604@51B5FDF91356B2B4E943EF72648EB0AD@6F2400488B04EBF66A60336B795EA142@8E51B8DCF87A7A02B84A2CAA5FF
CA3CF@89080D683268481694DBA6D1E22A2EFF@8F56225C76854A434385A09C319BF9C3@9AB0A3F199183F479F8887D1C3341B1B@845FE0D711086CC2D086546CD26B35C1@9D93A9BE1D2EDE216AA9EB
F26BF414BE: Internal Server Error at E:\pp2.pl line 17
I get same "Internal Server Error" when I go to same URL. Possible causes:
You didn't set referer correctly.
You have some authentication, which you do in browser, or any other data stored in cookie.
In general, opening URL in other browser, is a good way to check such things. "Live http headers" Firefox extension is a good way to check for such things.
another possibility the "Internal Server Error" error is your connection was reset
精彩评论