Install and load
Run these commands in a Haybarn SQL session. The extension is available from the community repository.
INSTALL html_query FROM community;
LOAD html_query FROM community;
Using upstream DuckDB? Follow the maintainerβs installation instructions.
Usage example
Extract text from first matching element
-- Extract text from first matching element
SELECT html_query('<html><title>Hello World</title></html>', 'title', '@text');
βββββββββββββββ
β html_query β
β varchar β
βββββββββββββββ€
β Hello World β
βββββββββββββββ
-- Extract all matching elements as VARCHAR[]
SELECT html_query_all('<div><p>First</p><p>Second</p></div>', 'p', '@text');
ββββββββββββββββββ
β html_query_all β
β varchar[] β
ββββββββββββββββββ€
β [First,Second] β
ββββββββββββββββββ
-- Extract JSON from LD+JSON scripts (returns array)
SELECT html_extract_json(
'<script type="application/ld+json">{"name":"Product"}</script>',
'script[type="application/ld+json"]'
);
ββββββββββββββββββββββββββββ
β html_extract_json β
β varchar β
ββββββββββββββββββββββββββββ€
β [{"name":"Product"}] β
ββββββββββββββββββββββββββββ
Provided by midwork-finds-jobs. Not yet verified on Haybarn 2.0.0.
Sample data & setupAbout this extension
html_query is a DuckDB extension for querying HTML using CSS selectors.
The extract parameter specifies what to extract from matched elements:
Project overview from the community descriptor.
Documentation and resources
Project and build details
- Repository
- midwork-finds-jobs/duckdb_html_query
- License
- MIT
- Maintainers
- onnimonni
- Written in
- Rust
- Build source
87af2dc57ae7- Build definition
- Community descriptor