Web scraping for research
Web scraping for research collects a study's data from public websites: article metadata, forum posts, news coverage, government statistics or Wikipedia revisions. Zenrows fetches those pages, JavaScript-heavy and protected ones included, and returns HTML, Markdown or JSON, so your methods section records exactly what was collected, from where and when.
Updated
{
"study_id": "housing-discourse-2026",
"record_id": "r-000184",
"source_type": "public forum",
"url": "https://forum.example.org/t/rent-increase-notice/48213",
"collected_at": "2026-10-17T09:41:27Z",
"request": { "mode": "auto", "response_type": "markdown" },
"http_status": 200,
"content_sha256": "3b1f0c9a...",
"title": "Rent increase notice after lease renewal",
"published": "2026-09-30",
"author_id": "u_7f3a (pseudonymized)",
"word_count": 412,
"replies": 23,
"language": "en",
"inclusion": { "matched_terms": ["rent increase", "lease"], "excluded": false }
}
What researchers collect from the web
Researchers scrape when the data a question needs is not yet a clean dataset.
The most common sources:
| Job | Data you collect | Typical sources |
|---|---|---|
| Literature and citation mapping | Title, authors, venue, year, DOI, abstract, citations | |
| Social science corpora | Posts, comments, timestamps, threads, votes | |
| Media framing studies | Headline, text, section, date, byline | News sites and archives |
| Policy and legislative analysis | Bills, consultation responses, committee reports, agency statistics | parliament.uk, europa.eu, state legislatures, national statistics offices |
| Economics and price research | Prices, attributes, availability on a fixed schedule | Retailer and marketplace pages |
| Knowledge production studies | Revisions, edit histories, talk pages, contributor counts |
Why research data collection goes wrong
A prototype scraper rarely survives peer review; the worst failures leave silent gaps or cannot be explained.
A reviewer asks how the corpus was built; the script no longer runs
Each request is a URL plus explicit parameters, so the log documents every fetch
Google Scholar or a publisher serves CAPTCHAs midway; gaps skew the sample
Zenrows' stealth keeps the run going; retry failed URLs until complete
Comments, citations or tables load late, absent from raw HTML
Adaptive Stealth Mode renders only when the page needs it
Menus, ads and cookie banners in the text your coders annotate
Markdown output returns clean text for annotation or NLP
Search shows the first results; you need every thread in a section
Crawl follows pagination, keeping every URL matching your pattern
Different results by visitor country
Geotargeting fixes the country, which you report in your methods
How to use web scraping for research
- Write the collection protocol first: sources, inclusion rules, dates, fields, pace; ethics approval if people are involved.
- Use official APIs and dumps where they exist (Wikipedia, arXiv, Crossref); scrape the rest.
- Build the sample frame with Crawl: every in-scope URL before any content, saved with the dataset.
- Fetch with fixed parameters and log everything: URL, time, parameters, status and hash per record, paced per domain.
- Archive raw responses to re-code later without recollecting.
# Fetch a sample frame politely and log provenance for every record
# pip install requests
import csv, hashlib, time, requests
from datetime import datetime, timezone
PARAMS = {"mode": "auto", "response_type": "markdown"}
urls = [line.strip() for line in open("sample_frame.txt") if line.strip()]
with open("collection_log.csv", "a", newline="") as log:
writer = csv.writer(log)
for i, url in enumerate(urls):
r = requests.get("https://api.zenrows.com/v1/",
params={"apikey": "YOUR_ZENROWS_API_KEY", "url": url, **PARAMS})
digest = hashlib.sha256(r.content).hexdigest()
with open(f"raw/{i:06d}.md", "wb") as f:
f.write(r.content)
writer.writerow([i, url, datetime.now(timezone.utc).isoformat(),
r.status_code, digest, PARAMS])
time.sleep(2) # pace requests per your protocolcurl -X POST "https://api.zenrows.com/v1/crawls" \
-H "X-API-Key: YOUR_ZENROWS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "FORUM_SECTION_URL",
"max_items": 5000,
"include_patterns": ["/t/"],
"exclude_patterns": ["/u/", "/login"]
}'npx -y @zenrows/cli init
zenrows crawl create FORUM_SECTION_URL --include-patterns /t/ --max-pages 5000 --follow
zenrows crawl results CRAWL_ID --out sample_frame.jsonl
zenrows fetch https://en.wikipedia.org/wiki/Open_science --output markdown# Connect once
claude mcp add zenrows -e ZENROWS_API_KEY=YOUR_ZENROWS_API_KEY -- npx -y @zenrows/mcp
# Then ask:
Use Zenrows to read the first five Google Scholar results pages for "misinformation" "social media" since 2020 and return a table of title, authors, year, venue and citation count, so I can check the scope before I write my collection protocol.Which Zenrows product fits
- Collect pages from a fixed URL list FetchOne request per page, explicit parameters; HTML, Markdown or named fields
- Build a sample frame for a site section CrawlFollows links and pagination, returns every matching URL
- Collect tens of thousands of pages BatchOne job, each task keyed with your record ID
- Scope sources before writing a protocol MCP ServerClaude or Cursor read a few pages through Zenrows and summarize them
What success looks like
| Measure | What good looks like | How to check it |
|---|---|---|
| Sample completeness | Each frame URL has a response or a logged, explained failure | Log against frame before analysis |
| Reproducibility | Others can rerun from your URL list and parameters | Publish list, code and parameters; test a subset rerun |
| Provenance | URL, fetch time, parameters and hash on every record | Check the final schema for missing fields |
| Data minimization | Only the fields protocol and ethics approval allow | Audit fields against protocol before sharing |
| Load on sources | Requests per domain within your protocol's pace | Requests per domain per minute in the log |
Web scraping for research FAQ
-
Many universities and funders accept web data, and several jurisdictions have research text and data mining exceptions: Article 3 of the EU copyright directive, section 29A of the UK copyright act. Site terms and privacy law still apply; ask your research office or counsel first.
-
Data about people (posts, comments, profiles) is usually human subjects research, reviewed by an ethics board or IRB. Pseudonymize usernames, keep only needed fields, store securely, and avoid identifying verbatim quotes.
-
Save the frame, code, parameters and a per-record log (URL, time, status, hash), and archive raw responses. Pages change, so reruns will not match byte for byte, but others can see what you collected and repeat the method.
-
Slowly enough that the site would not notice. Set a per-domain pace (say, one request every few seconds for small sites), read robots.txt, and spread large runs over days. Zenrows handles access; pace is your ethics call.
-
Yes. Google Scholar has no public API and serves CAPTCHAs after a few automated queries. Fetch results through Zenrows' stealth for title, authors, venue, year and citations, then enrich each record from Crossref or the publisher's page by DOI.
-
Crawl the section for thread URLs in your date range, fetch each as Markdown or named fields (text, handle, timestamp, reply depth), and pseudonymize handles. Pilot a few hundred threads, check pagination in long ones, and fix the protocol before the full run.
-
Share the URL list, code and log openly. Raw content may be copyrighted or personal, so many projects publish identifiers and derived variables and share full text under a data use agreement.
-
Yes, when the data is on web pages, not in a file. Use Markdown for text models or CSS-selected fields for tables, load into pandas, and keep the provenance log.