dphw5101 2012-06-10 16:56
浏览 39
已采纳

尝试使用curl下载文件,其中文件下载被javascript阻止?

I am trying to use curl to download a torrent file the url is

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

You will notice that upon getting to the page the download of the file is blocked for a few seconds via javascript, I was wondering if there is anyway to bypass this while using curl and php?

Thanks

  • 写回答

1条回答 默认 最新

  • doucou1892 2012-06-10 17:18
    关注

    The file is not blocked via javascript, that's just an informal message if you request that file. The redirect then is done via javascript.

    You can simulate the request your own, the important part here is that you add the HTTP Referrer request header. Example:

    $ 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
    

    Referrer is one thing to check, mind the typo in the HTTP specs, see Wikipedia.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度