Home > Uncategorized > Export Google Search Results to CSV

Export Google Search Results to CSV

I just wrote a handly function which uses the Google API to do a search, then export the results in CSV, for easy import into a database for further processing. Be aware, that this will probably max out your quota with one call, so be careful with it.

public void GoogleSearchToCSV(string SearchString, string FileName)


GoogleSearchService.GoogleSearchService gss = new GoogleSearchService.GoogleSearchService();

string CSV = "";



for(int i=170;i<10000;i+=10)


GoogleSearchService.GoogleSearchResult gsr = gss.doGoogleSearch("L3Pyyh5QFHKU740wXUu0/aBu17loGATB",SearchString,0,10,


foreach(GoogleSearchService.ResultElement reSearch in gsr.resultElements)


CSV += reSearch.title.Replace(",","").Replace("n","") + ",";

CSV += reSearch.snippet.Replace(",","").Replace("n","") + ",";

CSV += reSearch.URL.Replace(",","").Replace("n","") + "n";


Debug.Write("Progress:" + i.ToString());



catch(Exception ex)




FileStream fsOut = new FileStream(FileName,FileMode.Create);

StreamWriter swOut = new StreamWriter(fsOut);




Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: