2

while downloading the html source code of http://www.orientalcuisines.in/ this site, In result I am getting only script data not whole html content, I tried using webclient as well as httpwebrequest.

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://" + website);

        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        if (response.StatusCode == HttpStatusCode.OK)
        {
            Stream receiveStream = response.GetResponseStream();
            StreamReader readStream = null;

            if (response.CharacterSet == null)
            {
                readStream = new StreamReader(receiveStream);
            }
            else
            {
                readStream = new StreamReader(receiveStream, Encoding.GetEncoding(response.CharacterSet));
            }
            string data = readStream.ReadToEnd();

            response.Close();
            readStream.Close();
          }

OR

        using (WebClient client = new WebClient()) 
        {
         client.DownloadFile(website);
         }
  • 1
    Possible duplicate of [Get the final generated html source using c# or vb.net](http://stackoverflow.com/questions/14847656/get-the-final-generated-html-source-using-c-sharp-or-vb-net) – Zein Makki Jul 14 '16 at 05:56
  • Works for me, where is your code so that we can see if there is a problem? Add it to your question. – Esko Jul 14 '16 at 05:58
  • I dont want to run that on DocumentCompleted event –  Jul 14 '16 at 06:04
  • WebClient.DownloadFile does not have an overload with just 1 parameter: https://msdn.microsoft.com/en-us/library/system.net.webclient.downloadfile(v=vs.110).aspx Also if you want the html-content, use DownloadString instead. – Esko Jul 14 '16 at 07:12

0 Answers0