我怎么能只下载页面的一部分? [英] How can I download only part of a page?
本文介绍了我怎么能只下载页面的一部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我的网站上100页,但我想只下载部分的页面,而不是所有的页面内容。
I have 100 pages on my site, but I want download only part a page instead of all page content.
我希望每个页面只有一个框下载,文件大小为10 KB。
为此,我使用Web客户端和htmlagilitypack
I want just one box of each page to download, the file size is 10 KB. For this I Use WebClient and htmlagilitypack .
WebClient Client = new WebClient();
var result = Encoding.GetEncoding("UTF-8").GetString(Client.DownloadData(URL));
推荐答案
不幸的是,这是不可能的,因为HTTP是不是旨在提供的网页的特定部分的。它支持范围请求的,但你需要知道究竟何处(以字节为单位)所需的内容所在。
Unfortunately, that's not possible, because HTTP is not designed to deliver a specific part of a web page. It does support range requests, but for that you would need to know where exactly (in terms of bytes) the desired content is located.
您可以
- 下载整个页面,然后
- 使用一个HTML的解析库中提取您需要的部分。
这篇关于我怎么能只下载页面的一部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文