Prompt
structured data extraction from web pages
Latest observation
Oct 21, 2026
OpenAI APIWeb search: off
Structured data extraction from web pages usually means turning messy HTML into clean, usable fields like:
- title
- author
- date
- price
- product name
- address
- contact info
- article text
- table rows
Common approaches
1. Parse the DOM directly
Use a library to load the page HTML and extract elements with CSS selectors or XPath.
Best for:
- pages with stable HTML structure
- single-site scraping
- custom field extraction
Tools:
- Python: BeautifulSoup, lxml, Scrapy
- JavaScript: Cheerio, Puppeteer, Playwright
2. Use embedded structured data
Many pages already include machine-readable formats like:
- JSON-LD
- Microdata
- RDFa
For example, JSON-LD often contains schema.org data such as:
ArticleProductOrganizationBreadcrumbList
Best for:
- e-commerce pages
- news articles
- pages that follow schema.org
3. Use table extraction
If the data is in HTML tables, extract rows and columns directly.
Best for:
- pricing tables
- stats pages
- financial data
- comparisons
4. Use browser automation for dynamic pages
If content is rendered with JavaScript, use a headless browser to render the page first.
Tools:
- Playwright
- Puppeteer
- Selenium
5. Use an LLM or NLP post-processing layer
If the page content is unstructured, you can first extract text, then use an LLM to map it into a schema.
Best for:
- semi-structured pages
- inconsistent layouts
- forms with many variations
Typical workflow
- Fetch the page
- Detect whether the page uses JSON-LD or other metadata
- Parse the HTML and locate target fields
- Clean and normalize values
- Validate against a schema
- Store as JSON/CSV/database rows
Example output schema
{
"title": "",
"url": "",
"published_date": "",
"author": "",
"description": "",
"price": "",
"currency": ""
}
Example in Python
import requests
from bs4 import BeautifulSoup
url = "https://example.com"
html = requests.get(url).text
soup = BeautifulSoup(html, "html.parser")
title = soup.select_one("h1").get_text(strip=True) if soup.select_one("h1") else None
print({"title": title, "url": url})
Best practices
- Prefer official APIs if available
- Respect robots.txt and site terms
- Handle pagination and lazy loading
- Normalize dates, currencies, and units
- Add retries and error handling
- Log missing or malformed fields
- Validate extracted data with a schema
If you want this for a specific use case
I can help with any of these:
- extracting data from news pages
- extracting product data from ecommerce pages
- extracting tables from HTML
- building a crawler
- writing a Python/JavaScript scraper
- extracting JSON-LD automatically
If you want, I can give you:
- a general extraction architecture,
- code examples in Python or JavaScript, or
- a scraper for a specific webpage structure.