Lee Foot

Auto CSS Selector Detector

Find the CSS selector for a page's main content with an LLM, then extract that content as plain text.

View the source

#about

Finds the CSS selector for a page's main content and returns that content as plain text, one URL per run.

With navigation, headers, footers and sidebars stripped, an LLM picks from the five longest top-level containers (OpenAI's GPT Luna by default).

Its choice is narrowed to the innermost container holding at least 80% of the text and the content's H1.

If neither selector matches, a scoring heuristic takes over and says so.

Run it locallyAPI key or local model

Platform
Streamlit app you run on your own machine (needs Python 3.x)
Input
URL to analyseAPI key (OpenAI or compatible provider)Model name (default: gpt-6-luna; gpt-6.1-terra on OpenAI, or your local server's model name)Base URL (changeable for local LLM servers)
Output
For one URL: the selector the model chose, a narrowed specific selector, the reasoning, which of them the content was extracted from, the extracted content as plain text (downloadable as extracted_content.txt) and the internal links found in it.
Category
Content

Use cases

  • Extracting main content from pages without knowing the CSS structure
  • Building content extraction pipelines for unfamiliar sites
  • Finding a starting selector for scraping or migration tools (check it on the page first)
  • Converting page content to clean Markdown for analysis

#features

  • LLM-powered CSS selector detection via structural summaries
  • Selector narrowed to the innermost container that still holds the content
  • Non-content stripping: nav, header, footer, aside, script, style
  • Class and ID filtering for menu, sidebar, footer, header patterns
  • Content deduplication via SequenceMatcher (0.8 similarity threshold)
  • Internal link extraction from converted Markdown
  • Supports any OpenAI-compatible API (local LLMs, OpenRouter, etc.)
  • Default model: GPT Luna, with GPT Terra as the stronger OpenAI option

#how-to-use

  1. Enter your API key in the sidebar
  2. Optionally change the model or base URL for local LLM support
  3. Paste a URL and click Detect & Extract
  4. Review the detected selector and LLM reasoning
  5. View the refined specific selector and internal links found
  6. Download the extracted content as a .txt file

#faq

How does the tool decide which CSS selector contains the main content?
It lists the top-level containers of the page (div, main, article and section elements directly under body), leaves out navigation, headers, footers and sidebars, and measures the text in each. A summary of each container (its selector, text length and a 200-character sample) is sent to the LLM, which returns the best selector as JSON. Only the five longest containers are included. If the model returns a selector that matches nothing on the page, the longest container is used instead and the reasoning says so.
What does the 'specific selector' refinement do?
Starting from the container the LLM chose, the tool steps into a child container while that child holds at least 80% of the text, and stops before it would leave out the content's H1. The result is the innermost wrapper that still holds the content. It is written as a selector that matches one element: an id where the id is unique on the page, otherwise an nth-of-type path from body.
How is duplicate content handled in the extracted text?
After converting to Markdown and stripping links and images, paragraphs are compared pairwise using difflib SequenceMatcher. Any paragraph with a similarity ratio above 0.8 against an already-kept paragraph is dropped. This removes near-identical boilerplate but can also discard legitimately repeated content.
Can I use a local LLM instead of OpenAI?
Yes. The tool uses the OpenAI client library, so any server exposing an OpenAI-compatible /v1/chat/completions endpoint works. Change the Base URL field in the sidebar to your local server (e.g. http://localhost:1234/v1 for LM Studio) and enter any non-empty string as the API key. The model must support JSON response format.
What happens if the LLM picks the wrong selector?
The content is extracted from the narrowed selector, so a wrong choice gives you the wrong text. Check the 'Content extracted from' line and the extracted text against the page; the tool does not test the choice against any ground truth. If neither selector matches any content, it falls back to a scoring heuristic that favours the element with the most words and the fewest links, and reports that it did so.

/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.