Is there a way to fetch the first image source from google search if I have a search term?
For example if input is
tomato, ouput would be
Google Custom Search API now includes images. You are limited to 100 queries/day before billing, but it is the only legitimate way to use Google to do your searching for you.
If the link misdirects:
There is more than one way to invoke the API:
Representational State Transfer, in the Google Custom Search API is somewhat different from traditional REST. Instead of providing access to resources, the API provides access to a service. As a result, the API provides a single URI that acts as the service endpoint.
You access the Google Custom Search API service endpoint using the GET REST HTTP verb, as described in API operations. You pass in the details of all search requests as query parameters.
The specific format for the single Google Custom Search API URI is:
where parameters are any parameters to apply to the query. See Working with search results and and Query parameter reference in the Using REST document for details.
Here is an example of how this works in the Google Custom Search API, which searches a test Custom Search Engine for lectures:
The following example uses this approach to display the first page of search results for the query tomato:
You would, of course, update the src of the script to include the value of the input from which you are searching.
You can use the Google Image Search API to do this. Unfortunately it has been depracated so you may find the number of queries per day you can make to be limited. I am unsure if there is a new API to replace it.