任何人都可以帮助解释为什么下面的代码无法检索html
Dim WebReqeust As WebClient = New WebClient
Dim URL as string = "http://www.professionalorganizervannuys.com"
Dim WebPage As String = WebReqeust.DownloadString(URL)
此特定网址失败。
提前致谢。
答案 0 :(得分:2)
将用户代理包含在WebClient标头集合中。我能够通过以下内容获得html。
Dim WebRequest As WebClient = New WebClient
WebRequest.Headers(HttpRequestHeader.UserAgent) = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)"
Dim URL as string = "http://www.professionalorganizervannuys.com"
Dim WebPage As String = WebRequest.DownloadString(URL)