locked
System.Net.WebRequest.Create cannot download all html code RRS feed

  • Question

  • User531613705 posted

    Hi All,

    i am using System.Net.WebRequest.Create(url) to download html code, but it missed some data.  if i use IE to view page and click  "view source",  all data will be showed.  any idea?

    thanks in advance.

     

    my code:

    Dim req As System.Net.WebRequest
    Dim resp As System.Net.WebResponse

    req = System.Net.WebRequest.Create(url)
    resp = req.GetResponse()

    st = resp.GetResponseStream()
    sr = New System.IO.StreamReader(st, System.Text.Encoding.UTF8)
    result = sr.ReadToEnd

    sr.Close()

    st.Close()

     

    Wilson

    Sunday, November 8, 2009 2:06 AM

Answers

  • User-1659704165 posted

    Hi,

    U may use webclient..

    http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx

    Or
    WebRequest and webresponse

    http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 8, 2009 2:37 AM

All replies

  • User-1179452826 posted

     Try calling Flush() on the stream reader before closing it.

    Sunday, November 8, 2009 2:34 AM
  • User-1659704165 posted

    Hi,

    U may use webclient..

    http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx

    Or
    WebRequest and webresponse

    http://msdn.microsoft.com/en-us/library/system.net.webrequest.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 8, 2009 2:37 AM
  • User531613705 posted

    i have tried but it doesn't work.   

    Thanks for your reply.

     

     

    Sunday, November 8, 2009 11:01 AM
  • User531613705 posted

    the webclient works.  thanksLaughing 

     

    what is the difference between webclient and webrequest?

     

     Wilson

    Sunday, November 8, 2009 11:11 AM