pinews
V2EX  ›  问与答

小白请教抓取网页,预期 404 或者 2M 内的网页,但是突然遇到 300M 的文件,怎么在全部下载完之前识别到?

  •  
  •   pinews · Dec 19, 2020 · 2322 views
    This topic created in 2011 days ago, the information mentioned may be changed or developed.
    curl 试了好像暂时没找到办法!
    4 replies    2020-12-19 23:28:20 +08:00
    ysc3839
        1
    ysc3839  
       Dec 19, 2020
    你是用 shell 脚本调用 curl 吗?用 --max-filesize 参数。
    pinews
        2
    pinews  
    OP
       Dec 19, 2020
    php_curl

    谢谢,我试试!
    ClericPy
        3
    ClericPy  
       Dec 19, 2020
    流式读写? 开始读之前先像楼上说的 Headers 里面看看 content-length

    具体什么场景没描述, 就随便回复了下
    orcusfox
        4
    orcusfox  
       Dec 19, 2020 via iPhone
    curl -X HEAD
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1065 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 23:02 · PVG 07:02 · LAX 16:02 · JFK 19:02
    ♥ Do have faith in what you're doing.