Is it possible to read only first N bytes from the HTTP server using Linux command?

前端 未结 5 1422
梦如初夏
梦如初夏 2020-12-14 16:52

Here is the question.

Given the url http://www.example.com, can we read the first N bytes out of the page?

  • using wget, we can
5条回答
  •  暖寄归人
    2020-12-14 17:48

    You should also be aware that many HTTP/1.1 servers do not have this feature enabled, so that when you attempt to get a range, you'll instead get the whole document.

    You will have to get the whole web anyways, so you can get the web with curl and pipe it to head, for example.

    head

    c, --bytes=[-]N print the first N bytes of each file; with the leading '-', print all but the last N bytes of each file

提交回复
热议问题