Wolfram Research

Function Repository Resource:

FirstWebImage

Source Notebook

Get a single image from a web search

Contributed by: Bob Sandheinrich

ResourceFunction["FirstWebImage"][query]

retrieves an image for the specified query.

ResourceFunction["FirstWebImage"][query,elems]

gives the elements of the web image search specified by elems.

Details and Options

ResourceFunction["FirstWebImage"] requires internet connectivity and uses external services that require Service Credits.
The query can be any form supported by WebImageSearch.
The elems can be any element supported by WebImageSearch or their singular form, such as "Thumbnail" and "Image".
The default element is "Thumbnail".

Examples

Basic Examples

Get a thumbnail image from a web search:

In[1]:=
ResourceFunction["FirstWebImage"]["Ultimate Frisbee"]
Out[1]=

Retrieve a full image:

In[2]:=
ResourceFunction["FirstWebImage"]["Toasted Ravioli", "Image"]
Out[2]=

Scope

Get the URL for the image:

In[3]:=
url = ResourceFunction["FirstWebImage"]["Wolfram Spikey", "ImageHyperlink"]
Out[3]=

Open it in a browser:

Applications

Find out what a colonial revolutionary looked like (or at least find someone with their name):

In[4]:=
AssociationMap[ResourceFunction["FirstWebImage"],
 ResourceData["Paul Revere's Social Network in Colonial Boston"][
  1 ;; 10, "Name"]]
Out[4]=

Properties and Relations

The result of FirstWebImage is equivalent to taking the first result of WebImageSearch:

In[5]:=
ResourceFunction["FirstWebImage"]["Baseball"]
Out[5]=
In[6]:=
First@WebImageSearch["Baseball"]
Out[6]=

FirstWebImage is simpler and faster for getting a single image:

In[7]:=
{AbsoluteTiming[
  ResourceFunction["FirstWebImage"]["Aardvark", "Image"]], AbsoluteTiming[First@WebImageSearch["Aardvark", "Images"]]}
Out[7]=

Resource History

License Information