=IMPORTFROMWEB() syntax and options

The =IMPORTFROMWEB( ) function requires 2 parameters to extract web data: 

  • a data source, i.e. the URL that describes the source of your data
  • a selector, i.e. the path to the data you want to import, using built-in selectors, XPath or CSS selectors

Here is the basic syntax of the function:

=IMPORTFROMWEB("data_source", "selector")

And like any other spreadsheet functions, the parameters can be either written in quotation marks, or by referring to a range of cell(s) that contain them:

=IMPORTFROMWEB(A2,B1) 

ImportFromWeb is luckily not limited to 1 single URL or 1 selector per function.
With the same function, you can extract up to 50 URLs (as long as they share the same layout) and as many selectors as you want. Just refer to a list of URLs (up to 50) and use a comma between each selector, just like this:

=IMPORTFROMWEB(A1:A50, "selector 1,selector 2,selector 3")

In Google Sheets, according to your locale settings, you may have to use commas or semicolons to separate parameters (comma being usually the notation used in English speaking countries).

Data sources

The data source is the 1st parameter you input in any =IMPORTFROMWEB( ) function.​

The data source is most commonly a webpage URL, but it can also a piece of HTML code or the ID of an HTML file that is hosted in a Google Drive.

You can learn more about data sources in this ressource.

Data selectors

In the =IMPORTFROMWEB( ) function, the data selector is the 2nd parameter and it describes the content you want to import. There are 4 types of selectors:

Options

The choice of options is what makes ImportFromWeb so powerful and flexible. Options are specified as the 3d parameter into any =IMPORTFROMWEB() function and can be added in two ways:

A text of keys and values:

=IMPORTFROMWEB("https://www.example.com", "table", "country_code:us")

You can combine multiple options, separating them by a comma (spaces after the comma are not compulsory): “country_code:us, js_rendering:true, compare:true”

A reference to a two-columns range:

=IMPORTFROMWEB("https://www.example.com", "table", "A3:B5")

The left column defines option names and the second column contains corresponding values.

Setup Options

You can discover all available options on the following ressource

Additional parameters for Regular Expressions (advanced)

IMPORTFROMWEB automatically formats dates, numbers, and currencies for your spreadsheet, but the extracted data isn’t always ready for immediate use. To help with this, advanced users can use regular expressions – powerful search patterns – to clean or transform data directly within the function using the third and fourth parameters: regexps and replaceBy.

These optional parameters allow you to extract or replace specific text elements tied to each selector, providing greater control over how your data is processed. You can find more details on how to use regex in the following ressource.