2
Answers

How to download a complete web page source code

balaji palani

balaji palani

8y
303
1
Hi,
 
I need to download a complete html Source code below url.
 

 

 

http://bireports.education.ohio.gov/Microstrategy/asp/Main.aspx?evt=2048001&hiddensections=header%2Cpath%2CdockTop%2CdockLeft%2CdockBottom%2Cfooter%2Clinks&visMode=0&documentID=8259143A4C918098E4DAE397F7B89CDD&elementsPromptAnswers=50C135904A900677342F92A91D6A8612%3B50C135904A900677342F92A91D6A8612%3A047241&Server=EDUMSTRISP02&Port=0&Project=ReportCard&

 
 
 
 
I tried below code:
  1.   
    using (WebClient client = new WebClient()) // WebClient class inherits IDisposable
    {
    client.DownloadFile(url, @"F:\localfile.html");
    // Or you can get the file content without saving it:
    string htmlCode = client.DownloadString(url);
    //...
    }
 after downloaded page look like:
 
 Not able to get the web page content 
 
Answers (2)
0
balaji palani

balaji palani

NA 209 23.3k 8y
Hi Nitin,
I know about that, just this is a static web page. i tried to get a raw HTML content (without css,images..etc ).
no need to display the proper html content.
0
Nitin Sontakke

Nitin Sontakke

NA 11.7k 2.2k 8y
Hello,
While I don't mean to discourage you, tasks such as these are becoming increasingly difficult as not all contents are formatted as html anymore.
For example, there are several images, ccs files involved which are required for proper display of the html content.
Furthermore, these must be correctly resolved in a downloaded file, which is tricky to achieve.
Your downloaded file might continue to download / refer to the content on the server.
Hope you see what I mean.