Skip to content Skip to sidebar Skip to footer

Downloading A "complete" Webpage Programmatically?

I am using C# and I want to download a Complete web page Programmatically......I mean not only the page source I want the webpage to be downloaded the same as 'save page as' in Fir

Solution 1:

You need to download and parse the page to find out all the external resources, then download each in turn (and possibly parse it and download the resources within it).

For parsing the HTML, I suggest using the HTML Agility Pack. You need to keep in mind what resources you want to download (images, css, javascript etc) and query the page for those specifically.

You will need to keep in mind that some pages will define a base and that you will need to consider that as well as the page URL with relative and absolute links.

You may also want to parse the CSS for things like image references.

To finish off, you will want to change all these references to local ones that point to where the resources have been downloaded to (thanks @Scott M).

Post a Comment for "Downloading A "complete" Webpage Programmatically?"