C# 网络客户端标题
我正在使用WebClient来抓取谷歌搜索。 一直以来我都觉得“无法到达此页面” 在我更改用户代理标题之前:C# 网络客户端标题,c#,.net,webclient,C#,.net,Webclient,我正在使用WebClient来抓取谷歌搜索。 一直以来我都觉得“无法到达此页面” 在我更改用户代理标题之前: string page = string.Format("https://www.google.com/search?q={0}&hl=en", my_stocks[order].Symbole+" stock"); WebClient client = new WebClient (); client.He
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);
但是html呈现方式与我在chrome中搜索同一内容时不同。
因此,我尝试在使用chrome时将标题更改为相同
但再次获得“无法到达此页面”。
我在这里少了什么?我的2美分
由于单页应用程序的大量涌入,web抓取不再是过去的样子,因为页面通常不再在服务器端呈现
Google搜索很可能是使用异步REST查询而不是服务器端呈现的页面进行的
当你进行谷歌搜索时,在你的Chrome标签中查看网络跟踪,你可能会看到许多不同的网络请求
我建议您寻找一个更具体的API来处理您希望发出的请求类型