Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

downloading a "COMPLETE" webpage programmatically? [closed]

Tags:

html

c#

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 FireFox but i want to do this programmatically?

like image 908
Ahmad Houri Avatar asked May 02 '26 20:05

Ahmad Houri


1 Answers

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).

like image 159
Oded Avatar answered May 05 '26 09:05

Oded



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!