0

I need the get url's of Google search results to a text file, so I used the Google API like this:

GwebSearchClient client = new GwebSearchClient("www.MySite.com"/* Enter the URL of your site here */);
IList<IWebResult> results = client.Search("diet", 32);
foreach (IWebResult result in results)
{
     Console.WriteLine(result.Title);
     Console.WriteLine(result.Url);
}

This gets me the url's , BUT the next thing is that I need it to be the search results of a USA IP address...(and I am not in the USA) I need to set my IP as if I'm in the USA so that the search results will be as if I was doing the search from USA Is there any way to get this done ?

Liran Friedman
  • 4,027
  • 13
  • 53
  • 96
  • 2
    [System.Net.Dns.GetHostAddresses(string)](https://msdn.microsoft.com/en-us/library/system.net.dns.gethostaddresses(v=vs.110).aspx) should give you the IP and from the IP you can figure out the location – MilkyWayJoe Mar 11 '15 at 20:26
  • You can use this API to determine the location: http://ipinfodb.com/ip_location_api.php – mambrow Mar 11 '15 at 20:27
  • I didn't understand, I need to set my IP as if I'm in the USA so that the search results will be as if I was doing the search from USA... Is it possible in the solutions you gave me ? – Liran Friedman Mar 11 '15 at 21:12
  • You might want to rephrase your question then, cause from where I'm standing it seems like you initially asked to get the IP corresponding to the url of a given search result, and check if that IP is from the US – MilkyWayJoe Mar 11 '15 at 21:58

3 Answers3

1

Well a friend from work gave me the simplest solution, and it goes like this:

WebClient webClient = new WebClient();
webClient.Proxy = new WebProxy("proxy string");
string str = webClient.DownloadString("http://www.google.com/search?q=test");
Console.WriteLine(str);

and now just parse the html...

Liran Friedman
  • 4,027
  • 13
  • 53
  • 96
0

Use a Proxy Server based in the United States for your internet connection. Try: http://www.us-proxy.org/

Daniel C
  • 1,332
  • 9
  • 15
0

A suggestion:

1) Create a gmail account with country being usa and try be logged in on search. If you have already logged with an account of a different culture ( say UK and so on) just try to impersonate your account to an usa account of gmail. This should help.

[OR]

2) try proxy as suggested by Daniel. This link can help.

Community
  • 1
  • 1
codingninja
  • 58
  • 1
  • 7