【发布时间】:2020-05-02 10:11:46
【问题描述】:
我正在使用 WebClient 来抓取 google 搜索。 我一直收到“无法访问此页面” 直到我更改了 User-Agent 标头:
string page = string.Format("https://www.google.com/search?q={0}&hl=en", my_stocks[order].Symbole+" stock");
WebClient client = new WebClient ();
client.Headers["User-Agent"] = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)";
string r = client.DownloadString(page);
但是当我在我的 chrome 中搜索相同的东西时,html 呈现的不同。 所以当我使用带有https://www.whatismybrowser.com/detect/what-is-my-user-agent的chrome时,我尝试将标题更改为相同的 但再次获得“无法访问此页面”。 我在这里错过了什么?
【问题讨论】: