HTML parser: explore the DOM tree and copy selectors
Parse a page or HTML snippet into a navigable tree. Click any element to get its CSS selector and XPath, and see how the document is put together.
Showing a sample page so you can try things straight away. Fetch a URL or paste HTML to use your own.
Loading…
How to use it
- 1
Enter a page URL or paste HTML.
- 2
Expand the tree to find the element you care about. Search narrows it by tag, id, class or text.
- 3
Click an element to see its CSS selector, XPath, attributes and text.
Questions
- Will the tree match what my scraper sees?
- Yes, if your scraper parses HTML the way browsers do (the HTML5 algorithm, used by lxml's html5 mode, parse5, jsdom and others). Unclosed tags and missing <tbody> elements are repaired the same way a browser would.
- Are scripts on the page executed?
- No. The HTML is parsed into an inert document. Nothing in it runs and no images or other resources are loaded.
- How good are the generated selectors?
- They are unique on the page and prefer ids and meaningful class names over position. Classes that look machine-generated are skipped, because they change on every deploy.
Guides
Related tools
- CSS selector testerTry a selector against real HTML and see every match as you type.
- XPath testerEvaluate XPath against real HTML, including count() and string().
- Structured data extractorRead JSON-LD, Microdata, Open Graph and meta tags from any page.
Need the same data every day, or from many pages? Build a scraper by clicking what you want, then schedule it.