Content Block Extractor
Find the main content blocks on a set of pages, each with an XPath written by Claude Haiku.
#about
Lists the major content blocks on each page, each with a name and an XPath.
Claude Haiku reads the page once script, style, noscript, meta, link, header, footer and nav tags are removed, so blocks inside those are never returned, and HTML over 200,000 characters is cut.
The XPaths are written by the model and are not tested against the page.
Streamlit appRequires an API key
- Platform
- Browser-based (no installation required)
- Input
- One URL, a pasted list or a CSV with a URL column (app); a text file with one URL per line (command line)Anthropic API key
- Output
- CSV with one row per block per page: url, name, xpath, notes. A second file, combined_output_with_frequency.csv, adds a frequency column (the number of rows that share the XPath) and gives each XPath one name.
- Category
- Content
Use cases
- Identifying common template patterns at scale
- Finding content blocks for scraping or migration
- Analysing page structure consistency
- Generating XPaths for content extraction
#features
- Claude Haiku for block detection, or Claude Sonnet on the command line
- An XPath for each block
- HTML filtering removes nav, header, footer and scripts
- Frequency count of each XPath across pages
- Streamlit app or command line, with the same output
- Command line saves progress in batches and reports token use per page
#how-to-use
- Enter your Anthropic API key in the app sidebar, or set ANTHROPIC_API_KEY for the command line
- Give it the URLs: one URL, a pasted list or a CSV in the app, or a text file with --input on the command line
- Run it (there is a one second pause between pages)
- Review the blocks, then the frequency file to see which XPaths repeat across pages
- Check the XPaths against a page before using them in a scraper
#faq
- Should I use the app or the command line?
- Both use the same code and write the same files. The app suits a handful of pages: enter your Anthropic API key in the sidebar, then enter one URL, paste several or upload a CSV. The command line suits long lists: it reads a text file with one URL per line (--input), saves a batch file every 50 rows and takes the key from the ANTHROPIC_API_KEY environment variable. Use --limit 2 for a test run.
- Which Claude model does it use and what does it cost?
- Claude Haiku, one API call per page at medium effort, with a 16,000 output token cap that includes the model's thinking. The command line can use Claude Sonnet instead with --model claude-sonnet-5-5. Cost follows page size, and the thinking is billed as output tokens. The command line prints the token counts for every page, so a two-page test run (--limit 2) shows what your own pages will cost.
- Is the whole page sent to the model?
- No. The HTML is first stripped of script, style, noscript, meta, link, header, footer and nav elements, so blocks inside the header, footer or navigation are never returned. What remains is cut at 200,000 characters if it is longer (--max-html-chars on the command line), and the command line reports when a page was cut.
- How is the frequency column calculated?
- By exact string match on the XPath, across the pages in the current run. Two pages only count towards the same pattern if Claude returned character-identical XPath expressions for both, so near-identical selectors (a different class order, an added index) are counted separately. Block names are standardised afterwards: every row sharing an XPath gets the first name that appeared for it.
- What happens if a URL fails mid-run?
- A page that fails to download, or a reply with no usable JSON, is reported and skipped, and the run continues. The app lists the failed URLs with the error; the command line prints them at the end. The command line saves a batch file every 50 rows (--save-every), so a crash loses at most the rows since the last save. There is a one second pause before each page and a 30 second request timeout.
- Are the XPaths tested against the page?
- No. They are written by the model from the filtered HTML and are never evaluated. Check each one against a real page before using it in a scraper.
/contact
Want me to run this for you? I run this tool as a managed service, or build something custom around your data. You get the insights without touching the code.