doujingao6210 2011-05-18 16:46
浏览 356
已采纳

替代CURLOPT_RANGE来获取特定部分

I'm trying to use curl to fetch only a portion of a page so it will download less data thus making it quicker. I've been testing every possible option i can think of to no avail. The main one ive tried is defining a range: curl_setopt($ch, CURLOPT_RANGE, "0-4096");

The servers im trying this on are HTTP 1.1 but the setting has no effect as the entire page is pulled. Is there an alternative way to close the connection after X bytes in PHP or something along those lines?

  • 写回答

1条回答 默认 最新

  • dongshi9407 2011-05-18 18:02
    关注

    You can use your own write callback (CURLOPT_WRITEFUNCTION) and have that return an error once you've received enough data.

    An example using such a write callback can be found here: http://curl.haxx.se/libcurl/php/examples/callbacks.html

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

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料