2012-11-30 32 views
1

我在C#中編寫了一個工具,將搜索結果返回到Google搜索。但是,即使我關閉了cookies並刪除了瀏覽器歷史記錄。它仍然會返回我當地的搜索結果:芝加哥。我使用的URL是:Google機器人搜索返回本地結果

URL =「https://www.google.com/search?q=health和美容&即= UTF-8 & OE = UTF-8 &水溶液=噸& RLS = org.mozilla:EN-US:官方&客戶端= firefox的-A &開始= 0 & NUM = 9 & GL =我們」

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

我認爲這是一個Google問題,而不是編程問題。您需要從Google論壇尋求幫助。 (破壞者警報:我做了一個快速搜索,發現沒有解決方案,只是很多人抱怨) –

回答

0

不是擊中google.com,擊中google.ca,而是繼續傳入gl = us參數。所以,你的URL看起來像:

https://www.google.ca/search?q=health和美容&即= UTF-8 & OE = UTF-8 &水性= T & RLS = org.mozilla:EN-US:官方&客戶端= firefox的-A &啓動= 0 & num = 9 & gl = us

這似乎繞過了我測試過的搜索術語的geotargetting。

+0

聰明,男人感謝 – ling

+0

注意檢查它作爲答案? – Pete