Hi all,
I'm trying to write a console app that given a certain topic would download images related to that topic. My idea was to use the google image search results and then download some of those images in no specific order.
I create a small program in C# console that connect with google api and passes the essential parameters such as "project Id", "Google custom search Id" and the "query".
With the code bellow I'm able to do a search and get the first 10 results printed in the console. Now I need more info on how to access the image's url, and how to download them.
private void Run()
{
//Create the Service.
CustomsearchService service = new CustomsearchService(new BaseClientService.Initializer
{
ApiKey = "[My ApiKey from my Google project]",
});
//Specify the query to be searched.
CseResource.ListRequest listRequest = service.Cse.List("charcoal");
//Specify the Custom Search Engine.
listRequest.Cx = "[My Custom Engine Search ID]";
Search search = listRequest.Execute();
//Run the service.
Console.WriteLine();
Console.WriteLine("Executing my test request");
Console.WriteLine();
foreach (var searchresult in search.Items)
{
Console.WriteLine("Title: {0}", searchresult.Title);
Console.WriteLine("Link: {0}", searchresult.Link);
}
}