Google Robot Search返回本地结果

时间:2012-11-30 18:29:39

标签: c#

我在C#中编写了一个工具,用于在Google搜索中返回搜索结果。但是,即使我关闭cookie并删除了浏览器历史记录。它仍会返回我当地的搜索结果:芝加哥。我使用的URL是:

网址=“https://www.google.com/search?q=health and beauty& ie = utf-8& oe = utf-8& aq = t& rls = org.mozilla:en-US:官方&安培;客户=火狐-A和开始= 0试验#= 9&安培; GL = US“

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Accept = "application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
request.Headers["Accept-Language"] = "en-US";
//request.UserAgent = "Mozilla/6.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/16.0.2";
request.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";    
request.KeepAlive = true;
request.AllowAutoRedirect =true;
request.Timeout = 60000;
request.Method = "GET";


HttpWebResponse response = (HttpWebResponse)request.GetResponse();

if (response.StatusCode == HttpStatusCode.OK)
{
    Stream responseStream = response.GetResponseStream();
    StreamReader myStreamReader = new StreamReader(responseStream);
    responseData = myStreamReader.ReadToEnd();
}
response.Close();

在该工具中,它不断向我提供芝加哥的结果。有没有办法让我获得美国而不是芝加哥的结果?

1 个答案:

答案 0 :(得分:0)

点击google.ca而不是点击google.com,但继续传入gl = us参数。所以你的网址看起来像是:

https://www.google.ca/search?q=health和beauty& ie = utf-8& oe = utf-8& aq = t& rls = org.mozilla:en-US:official& client = firefox-a& start = 0& num = 9&安培; GL = US

这似乎绕过我测试过的搜索字词的地理位置定位。