Let’s learn how to run the IMPORTFROMWEB() function in Google Sheets and start scraping webdata.
You feel more confortable discovering it on a video? Check it out here
Install the add-on: if not installed yet, go to the install page.
Activate the add-on: when opening a new spreadsheet, don’t forget to activate the ImportFromWeb add-on.
The =IMPORTFROMWEB( ) function requires 2 parameters (or arguments) to extract data:
- the data source, i.e. an URL that describes the source of your data
- the selector, i.e. the path to the data you want to import
So, extracting data is as easy as typing:
A selector can be either:
- a generic selector (title, h1, metaTitle…) — click here to get the full list of generic selectors
- a built-in selector — designed for some mainstream websites such as Amazon, Yahoo Finance, Google Maps…
- An XPath or a CSS selector
More info on selectors here
Like any other spreadsheet functions, the arguments can be either written in quotation marks, or by referring to a range of cell(s) that contain them:
=IMPORTFROMWEB("https://www.example.com", "selector 1")
In Google Sheets, according to your locale settings, you may have to use commas or semicolons to separate parameters. Comma is usually the notation used in English speaking countries.
For this example, we’ll take the Empire State Building page and will retrieve its page title.
Exactly the same way, we can pull any other data from the page, such as its h2 content or its meta title (using the selector “h2” or “metaTitle”)
In this example, we will extract 3 Amazon products in your spreadsheet (yes, you can extract up to 50 URL at a time!)
1.1. Select in the 1st argument the range of cells containing the Amazon products URL
In our case A2:A4
1.2. Select in the 2nd argument the selectors from the Amazon built-in selectors list, let’s say for our example “title”, “price” and “rating”.
We write them in the following range of cells B1:D1
1.3. Validate your formula and voilà!
TIP: to extract a table from a website, just type “table” as the 2nd argument in your =IMPORTFROMWEB( ) function, as follow:
The ImportFromWeb sidebar offers you a lot of support to create your function and discover all its potential.
Open it through the menu Extension > ImportFromWeb > 🛠 Open sidebar.
Our templates are designed for a more simple web scraping process from the major websites, such as Google, Amazon, Yahoo Finance, LinkedIn, Instagram…
In the Monitor tab, find all the info about your data retrieval: monitor and get your functions meta data.
Through the Monitor tab, you fetch the latest data whenever you decide (with the RUN button) or you set up hourly, daily or weekly automatic updates.
Our video tutorial is also a good way to get started with ImportFromWeb!