我们需要每5分钟轮询一次网页,并且网页正在变得相当大。 网页是一个目录列表,我们需要最后一行(获取文件名)。 得到最后一行的最佳方式是什么?
(如果这是一个本地文件,我可以在文件末尾找一个相对位置并读取)。
We need to poll a web page every 5 minutes and the web page is growing rather large. The web page is a directory listing and we need the last line (to get a file name). What is the best way to get just this last line?
(If this was a local file I could position back a little relative to the end of file and read).
最满意答案
HTTP 1.1确实支持一组标题来只请求特定范围的字节,包括仅支持文件的最后n个字节(使用“后缀”格式)。 看到这里 。 例如,
Range: bytes=-1000为最后的1000字节。 (当然,假设服务器支持Range标头。)
HTTP 1.1 does support a set of headers to request only a particular range of bytes, including support for just the last n bytes of a file (using the "suffix" format). See here. For instance,
Range: bytes=-1000for the last 1000 bytes. (Assuming the server supports the Range header, of course.)
更多推荐
发布评论