Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 网络客户端标题_C#_.net_Webclient - Fatal编程技术网

C# 网络客户端标题

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

我正在使用WebClient来抓取谷歌搜索。 一直以来我都觉得“无法到达此页面” 在我更改用户代理标题之前:

            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来处理您希望发出的请求类型