Using IMPORTHTML in Google Sheets

When you want to import data from a list or a table displayed on a web page into Google Sheets, the IMPORTHTML function is available to help you.

The syntax is:

IMPORTHTML(url, query, index)

The url parameter is that address of the page from which you want to import data. Remember to include the protocol part, such as http://

The value of query should be either table or list, depending which type of HTML element you want to look for.

The parameter index is the number of the list or table as it appears in the HTML page. Note that these numbers start at 1, not at 0 as in some array indexing systems.

Here’s IMPORTHTML collecting the menu items from a webpage:

Click image to enlarge

Click image to enlarge

Each of these items is stored in a <li> element of a <ul> container; in this case it’s the first list item appearing in the page, hence index=1.

Instead of quoting the url parameter specifically, you can instead quote a spreadsheet location where the information appears:

Click image to enlarge

Click image to enlarge

This latter method may be useful when the URL data is dynamic, e.g. when the URL in question is being submitted via a form.

Don’t forget you can import tables as well as lists – here we’re grabbing some of Google’s documentation about spreadsheet functions:

Click image to enlarge

Click image to enlarge