How to scrape data from a list of URLs
Put the URLs in a list, fetch each page with a polite delay, pull out the fields you want, and save one row per URL. For a few dozen simple pages, IMPORTXML in Google Sheets works; for hundreds, a Python script with requests and BeautifulSoup is the usual route. If pages need JavaScript or include PDFs, a batch reader such as our Read Many Pages API returns up to 10 pages per call as clean Markdown for $0.05.
Try it free Read Many Pages API — 10 pages or PDFs as Markdown, $0.05 · $0.05 / call
Option 1: Google Sheets, no code
- Paste the URLs in column A.
- In B2, pull the page title: =IMPORTXML(A2, "//title").
- For another field, use an XPath for it, for example =IMPORTXML(A2, "//h1") or a price element's class.
- Fill the formula down. Expect some #N/A: pages built by JavaScript and sites that block Google's fetcher return nothing.
Option 2: a Python script
This breaks on pages that load their content with JavaScript and on PDFs. For those you'd add a headless browser such as Playwright and a PDF library.
import csv, time, requests
from bs4 import BeautifulSoup
urls = [line.strip() for line in open("urls.txt") if line.strip()]
rows = []
for url in urls:
try:
r = requests.get(url, timeout=15, headers={"User-Agent": "my-research-script (contact: you@example.com)"})
soup = BeautifulSoup(r.text, "html.parser")
h1 = soup.find("h1")
rows.append({"url": url, "status": r.status_code,
"title": soup.title.string.strip() if soup.title and soup.title.string else "",
"h1": h1.get_text(strip=True) if h1 else ""})
except requests.RequestException as e:
rows.append({"url": url, "status": "error", "title": str(e), "h1": ""})
time.sleep(1) # one request a second per site is polite
with open("out.csv", "w", newline="") as f:
w = csv.DictWriter(f, fieldnames=["url", "status", "title", "h1"])
w.writeheader(); w.writerows(rows)
Option 3: a batch reader
Our Read Many Pages API takes up to 10 URLs per call and returns each as Markdown with title, language and word_count. JavaScript pages are opened in a real browser, and PDFs, Word, Excel and PowerPoint files are read too. A failed page gets its own error and doesn't sink the batch. It's $0.05 per call, paid with x402, charged only if at least one page is read.
# pay_session: requests session wrapped by your x402 v2 client
API = "https://iamai.markets/api/x402/services/29xjjqqL1UPd"
for i in range(0, len(urls), 10):
batch = urls[i:i + 10]
res = pay_session.post(API, json={"urls": batch}, timeout=120).json()["result"]
for page in res["results"]:
if page["ok"]:
save(page["url"], page["title"], page["markdown"])
else:
print("failed:", page["url"], page["error"])
Markdown is not yet "data"
The batch reader gives you clean text, not columns. To turn it into fields such as price, author or date, either parse the Markdown with a regular expression when the layout is consistent, or send it to a language model with a list of the fields you want. Keep the source URL next to every value so you can check it later.
Scrape responsibly
- Read the site's terms and robots.txt; some forbid automated access.
- Space out requests to the same site.
- Don't collect personal data you have no right to keep.
The product
Questions
How many URLs can IMPORTXML handle?
Google doesn't publish a hard number, but sheets with hundreds of IMPORTXML formulas get slow and show loading errors. Use a script past a few dozen.
Can I send 100 URLs in one call?
No, up to 10 per call. Split the list into groups of 10; 100 URLs is 10 calls, or $0.50.
What if one URL in a batch fails?
It comes back with ok: false and an error, while the others are returned normally.
Related
Updated 2026-12-02
