CSS 選擇器

用 CSS 選擇器從 HTML 文檔中擷取匹配元素或字段。

輸入: 文本結果: 文本

文本輸入

工具選項

範例

Select a release download link by its class

The result contains the matching element, including its attributes.

輸入

<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 選擇器
a.download
分隔符
\n
Select only failed rows from a job report

輸入

<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 選擇器
tr.failed
分隔符
\n
Select links whose destination uses HTTPS

輸入

<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 選擇器
a[href^="https://"]
分隔符
\n
Select direct list children without nested checklist items

輸入

<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 選擇器
#steps > li
分隔符
|
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.

輸入

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

Expected answer

Empty result
CSS 選擇器
link[rel="canonical"]
分隔符
\n
CSS selector

輸入

<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 選擇器
#test p.a
分隔符
\n

参數

参數默認值輸入與選項
CSS 選擇器""文本
分隔符"\\n"支持 \n、\r 和 \t 等跳脫序列

相关工具

擷取

操作参考

查看原始技术文檔 (English)