Prompt
How do I scrape data from a website into Google Sheets?
Latest observation
You can scrape website data into Google Sheets a few different ways, depending on how the site is built and how much data you need.
1) Use built-in Google Sheets functions for simple pages
If the data is in plain HTML and publicly visible, you can sometimes use:
IMPORTHTML
Pulls tables or lists from a page.
=IMPORTHTML("https://example.com/page","table",1)
"table"or"list"1= first table/list on the page
IMPORTXML
Scrapes data from HTML using XPath.
=IMPORTXML("https://example.com/page","//h2")
Example for table cells:
=IMPORTXML("https://example.com/page","//table//tr//td")
Limits:
- Works only on pages that are publicly accessible
- Often fails on JavaScript-rendered content
- Sites may block it or change layout unexpectedly
2) Use Google Apps Script for custom scraping
If you need more control, use Apps Script inside Google Sheets.
Basic example:
- Open your Google Sheet
- Go to Extensions → Apps Script
- Paste code like this:
function scrapeExample() {
const url = "https://example.com";
const html = UrlFetchApp.fetch(url).getContentText();
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
sheet.clear();
// Very basic example: extract all links
const matches = [...html.matchAll(/<a[^>]*href="([^"]*)"[^>]*>(.*?)<\/a>/g)];
sheet.appendRow(["Link", "Text"]);
matches.forEach(m => sheet.appendRow([m[1], m[2].replace(/<[^>]*>/g, "")]));
}
This is useful when:
- You need to clean data before writing to Sheets
- You want to scrape multiple pages
- You need scheduling/automation
Note: Apps Script can fetch only pages accessible without login and may not handle complex JavaScript pages well.
3) Use a scraping tool or extension
If you don’t want to code, you can use:
- ImportFromWeb
- Instant Data Scraper
- Octoparse
- Apify
- ParseHub
Many of these can export directly to Google Sheets or CSV.
4) For JavaScript-heavy sites, use a browser automation tool
If the page content loads dynamically, use:
- Puppeteer
- Playwright
- Selenium
These can render the page like a real browser, then send the extracted data to Google Sheets via:
- Google Sheets API
- Apps Script web app
- CSV import
5) Use an API if the website provides one
If the site has an API, that’s usually the best option. It’s more stable and less likely to break than scraping HTML.
Example Apps Script approach:
function fetchApiData() {
const response = UrlFetchApp.fetch("https://api.example.com/data");
const data = JSON.parse(response.getContentText());
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
sheet.clear();
sheet.appendRow(["Name", "Value"]);
data.items.forEach(item => sheet.appendRow([item.name, item.value]));
}
Important notes
- Check the site’s terms of service and robots.txt
- Don’t scrape private or protected data without permission
- Be respectful with request volume to avoid blocking
- For large jobs, use rate limiting and caching
Quick recommendation
- Simple tables:
IMPORTHTML - Need XPath/data cleanup:
IMPORTXML - More control: Apps Script
- Dynamic pages: Playwright/Puppeteer/Selenium
- Best if available: official API
If you want, I can show you:
- a no-code method,
- a Google Apps Script example, or
- a script for a specific website.
Observation history
Unlock observation history
Create a free Obsurfable account to unlock historical responses, model comparisons, and deeper brand intelligence.
How did Obsurfable measure this prompt?
Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.
Which AI systems does Obsurfable collect answers from?
OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, and Meta AI.