我正在尝试连接到网站,但即使我可以在浏览器中访问该网站,它仍然会返回此错误:
An exception of type 'System.Net.WebException' occurred in System.dll but was not handled in user code
Additional information: The remote server returned an error: (404) Not Found.
我很确定我的代码是正确的,因为我最近经常使用相同的代码,但无法弄清楚为什么它返回错误,有什么建议吗? 我的代码:
OddsTodayREQUEST = WebRequest.Create("http://www.betexplorer.com/next/soccer/")
Using OddsTodayRESPONSE As WebResponse = OddsTodayREQUEST.GetResponse()
Using OddsTodayREADER As New StreamReader(OddsTodayRESPONSE.GetResponseStream())
OddsTodayHTML = OddsTodayREADER.ReadToEnd()
End Using
End Using
最佳答案
该站点希望将用户代理添加到请求中。您可以通过谷歌搜索我的用户代理是什么?
找到您自己的用户代理并按如下方式添加:
OddsTodayREQUEST.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)"
关于vb.net - WebRequest.GetResponse - 远程服务器返回错误 : (404) Not Found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46104734/