2012-06-10 106 views
0

我試圖使用curl下載torrent文件的網址是試圖使用curl下載文件下載被javascript阻止的文件?

http://torcache.net/torrent/006DDC8C407ACCDAF810BCFF41E77299A373296A.torrent

你會發現,一旦獲得該文件的下載被阻止通過JavaScript幾秒鐘的頁面,我想知道是否有反正在使用curl和php時繞過這個?

感謝

+1

使用Firebug(Firefox)查看要發送並複製的請求。或者開發者工具,如果你使用的是Chrome/Safari。 – nhahtdh

回答

2

該文件未通過JavaScript堵塞,如果你要求的文件,這只是一個非正式的消息。重定向然後通過javascript完成。

您可以模擬您自己的請求,這裏的重要部分是您添加HTTP Referrer請求標頭。例如:

$ curl -I -H 'Referer: http://torcache.net/torrent/006DDC8C407ACCDAF810BCFF41E77299A373296A.torrent' http://torcache.net/torrent/006DDC8C407ACCDAF810BCFF41E77299A373296A.torrent 
HTTP/1.1 200 OK 
Server: nginx/1.3.0 
Date: Sun, 10 Jun 2012 17:13:59 GMT 
Content-Type: application/x-bittorrent 
Content-Length: 10767 
Last-Modified: Sat, 09 Jun 2012 22:17:03 GMT 
Connection: keep-alive 
Content-Encoding: gzip 
Accept-Ranges: bytes 

引薦是一件事要檢查,介意在HTTP規範中的錯字,請參閱維基百科。

+0

感謝這真棒:)將嘗試和現在轉換爲PHP代碼,並得到它的工作:) – Griff

+0

工作第一次感謝:) – Griff