我写了一个脚本来获取谷歌搜索的热门网址。这个脚本的一个最大问题是,它会根据我的 IP 返回搜索结果。也就是说,我在芝加哥,它是从芝加哥而不是美国返回结果。我认为这可能与用户代理有关:
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";
有人知道我为什么要搜索本地吗?