c#webclient在工作页面上返回403和301。如何摆脱这个。这是我的代码。没有通过C#中的WebClient获取网页的页面源代码?
TimedWebClient wclient = new TimedWebClient();
//This is a object extend WebClient
byte[] pagesource = wclient.DownloadData(requestUrl);
UTF8Encoding objUTF8 = new UTF8Encoding();
string responseData = objUTF8.GetString(pagesource);
这适用于某些URL,但不与他人 例如:网址是:http://toyotaofmanhattan.com/
"The remote server returned an error: (403) Forbidden."}System.Exception {System.Net.WebException}
请帮我解决这个problem.Thank你。
它是一个https网址吗? – liquidsnake786
它可能检测到您没有用户代理并因此怀疑机器人或类似设备的事实。尝试设置一个用户代理;看到这个答案更多的信息:http://stackoverflow.com/a/2316128/1073107 – dash
只是使用尝试赶上,所以如果URL不会加载显示文本说例如抱歉不能加载具体的网址 – Sora