CSS selector

Extract information from an HTML document with a CSS selector

Input: TextResult: Text

Text input

Tool options

Examples

Select a release download link by its class

The result contains the matching element, including its attributes.

Input

<main><a class="download" href="/app.tar.gz">Linux</a><a href="/notes">Notes</a></main>

Expected answer

<a class="download" href="/app.tar.gz">Linux</a>
CSS selector
a.download
Delimiter
\n
Select only failed rows from a job report

Input

<table><tr class="passed"><td>Build</td></tr><tr class="failed"><td>Test</td></tr></table>

Expected answer

<tr class="failed"><td>Test</td></tr>
CSS selector
tr.failed
Delimiter
\n
Select links whose destination uses HTTPS

Input

<div><a href="https://example.org/docs">Docs</a><a href="/local">Local</a></div>

Expected answer

<a href="https://example.org/docs">Docs</a>
CSS selector
a[href^="https://"]
Delimiter
\n
Select direct list children without nested checklist items

Input

<ul id="steps"><li>Build<ul><li>Compile</li></ul></li><li>Deploy</li></ul>

Expected answer

<li>Build<ul><li>Compile</li></ul></li> | <li>Deploy</li>
CSS selector
#steps > li
Delimiter
|
Find a missing canonical link in a document head

An empty result means no matching element was found in this supplied HTML; no website is fetched.

Input

<html><head><title>Release notes</title></head><body>v2</body></html>

Expected answer

Empty result
CSS selector
link[rel="canonical"]
Delimiter
\n
CSS selector

Input

<div id="test">
<p class="a">hello</p>
<p>world</p>
<p class="a">again</p>
</div>

Expected answer

<p class="a">hello</p>
<p class="a">again</p>
CSS selector
#test p.a
Delimiter
\n

Format reference: CSS selector background and specification

Parameters

ParameterDefault valueInput and choices
CSS selector""Text
Delimiter"\\n"Escape sequences such as \n, \r and \t are supported

Related tools

Browse extractors tools