public int GetPosition(string keyword, string url) { GoogleSearchService gs = new GoogleSearchService(); int position = -1; try { GoogleService.GoogleSearchResult r = gs.doGoogleSearch(googleKey, keyword,0, 10, false, "", false, "", "", ""); // find out if we are in these results for (int i=0;i<r.resultElements.Length;i++) { if (r.resultElements[i].URL.IndexOf(url) >=0 ) { position = i+1; Console.WriteLine("We are rocking at number " + position); break; } } } catch (System.Web.Services.Protocols.SoapException ex) { Console.Write(ex.Message); } gs = null; return position; }
public int GetPosition(string keyword, string url) { GoogleSearchService gs = new GoogleSearchService(); int position = -1; int maxposition = 100; try { for (int j=0;j<maxposition;j=j+10){ GoogleService.GoogleSearchResult r = gs.doGoogleSearch(googleKey, keyword,j, 10, false, "", false, "", "", ""); // find out if we are in these results for (int i=0;i<r.resultElements.Length;i++) { Console.WriteLine("r {0}",r.resultElements[i].URL.ToString()); if (r.resultElements[i].URL.IndexOf(url) >=0 ) { position = j+i+1; Console.WriteLine("We are rocking at number " + position); break; } } if (position > 0) break; } } catch (System.Web.Services.Protocols.SoapException ex) { Console.Write("Error al obtener la posicion: {0}",ex.Message); } gs = null; return position; }
public int GetBackLinks(string url) { GoogleSearchService gs = new GoogleSearchService(); int backlinks = -1; try { GoogleService.GoogleSearchResult r = gs.doGoogleSearch(googleKey, "link:"+url,0, 1, false, "", false, "", "", ""); // find out if we are in these results backlinks = r.estimatedTotalResultsCount; } catch (System.Web.Services.Protocols.SoapException ex) { Console.Write(ex.Message); } gs = null; return backlinks; }