Published
Edited
Aug 2, 2022
10 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { DatasetteClient } from "@ambassadors/datasette-client"
Insert cell
db = new DatasetteClient("https://sqlite-html-demo.fly.dev/data")
Insert cell
Insert cell
db
select html_version(), html("It <b> works!");
Insert cell
Insert cell
Inputs.table(db.query("select * from pages"))
Insert cell
Insert cell
db
select
html_attr_get(html, 'a', 'href') as href,
text
from html_each(
(select page from pages where name = 'ca.gov'),
'a'
)
Insert cell
Insert cell
db
select
text as headline,
printf(
"https://text.npr.org%s",
html_attr_get(html, 'a', 'href')
) as link
from html_each(
(select page from pages where name = 'text.npr.org'),
'a.topic-title'
)
Insert cell
Insert cell
Inputs.table(
db.sql`
select
html_attr_get(html, 'link', 'href') as link
from html_each(
(select page from pages where name = 'whitehouse.gov'),
'link[rel=stylesheet]'
)`
)
Insert cell
Insert cell
db
select
html_text(items.html, "strong") as name,
html_attr_get(
html_extract(items.html, 'a[href*=".zip"]'),
'a',
'href'
) as href
from html_each(
(select page from pages where name = 'lacounty-results'),
'.expandable_item.indent'
) as items
Insert cell
Insert cell
scripts = db.sql`select
pages.name,
script_tags.rowid as id,
text as code
from pages
join html_each(page, 'script') as script_tags
where not html_attr_has(script_tags.html, 'script', 'src')`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more