Google API manipulation of the data with C# RRS feed

  • Question

  • 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("Executing my test request");
                foreach (var searchresult in search.Items)
                    Console.WriteLine("Title: {0}", searchresult.Title);
                    Console.WriteLine("Link: {0}", searchresult.Link);

    Tuesday, May 7, 2019 2:59 AM


  • //Specify the search type;
    listRequest.SearchType = CseResource.ListRequest.SearchTypeEnum.Image;

    • Marked as answer by Dandvv Tuesday, May 7, 2019 8:00 AM
    Tuesday, May 7, 2019 7:59 AM