How to load only part of the page?

I have 100 pages on my site, but I want to download only part of the page, not the entire content of the page.

I want to load only one cell of each page, 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)); 

enter image description here

+7
c #
source share
2 answers

Unfortunately, this is not possible because HTTP is not intended to deliver a specific part of a web page. It supports range queries , but for this you will need to know exactly where (in terms of bytes) the desired content is located.

You can

  • load the whole page and then
  • use the HTML parsing library to extract the part you need.
+7
source share

You cannot achieve this.

The solution only changes the structure of the website. if you have control over the server -

Change the architecture of your website by making the data in the window accessible through an ajax call. Now you can get data through WebClient. If this data has already been sent via an API call, you can point your WebClient to this URI.

Here is an example of structuring your ajax-based site - AJAX with jQuery and ASP.NET

0
source share

All Articles