ling
ling

Reputation: 185

C# Httpwebrequest Useragent

I wrote a scrip to get the Google Search top Urls. One biggest issue for this script is that, it is return the search result based upon my IP. That is to say,say, i am in Chicago, it is returning the results from location Chicago instead of US. I figure that can have something to do with the useragent:

 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/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";

Does anyone have ideas about why i am getting the search for local?

Upvotes: 0

Views: 6787

Answers (1)

Tomas Grosup
Tomas Grosup

Reputation: 6514

As http://support.google.com/websearch/bin/answer.py?hl=en&answer=179386 states, you can override the automatic location detection by specifying one directly in the search query.

If you'd like to see results for a region outside of your Google domain, please specify the location in the search query, like [ bicycle repair paris ] or visit a different Google local domain instead.

Upvotes: 1

Related Questions