Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Google.Apis.Customsearch.v1;
using Google.Apis.Services;
namespace GoogleSearchPOC.NetCore
class Program
static void Main(string[] args)
var result = GetResults().Result;
foreach (var r in result)
public static async Task<List<string>> GetResults()
string apiKey = "<apikey>";
string searchEngineId = "<searchengineid>";
string query = "project";
BaseClientService.Initializer init = new BaseClientService.Initializer();
init.ApiKey = apiKey;
using (var searchService = new CustomsearchService(new Google.Apis.Services.BaseClientService.Initializer { ApiKey = apiKey }))
var listRequest = searchService.Cse.List(query);
listRequest.Cx = searchEngineId;
var search = await listRequest.ExecuteAsync();
return search.Items?.Select(x => x.Link).ToList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.