简体   繁体   English

如何下载html文档的前几行?

[英]How can I download the first few lines of an html document?

How can I download the first few lines of an html document? 如何下载html文档的前几行? I have tried jsoup and httpclient but it seems that I still have to download the full document. 我已经尝试过jsoup和httpclient,但是看来我仍然必须下载完整的文档。 I only want some text from about the 15th line of a page and I would rather not have to download the entire several hundred line document to get it. 我只希望从页面的第15行开始输入一些文本,而不必下载整个数百行的文档来获取它。 This is being run from a service that updates a home screen widget. 这是通过更新主屏幕小部件的服务运行的。

Such thing isn't availaible in the HTTP protocol. 这样的事情在HTTP协议中不可用。 The only thing you can do is to use custom socket implementation to connect to the server directly and close the connection after receiving the data you want. 您唯一可以做的就是使用自定义套接字实现直接连接到服务器,并在收到所需数据后关闭连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM