Published
Edited
Nov 19, 2021
Insert cell
Insert cell
<h1>Comics</h1>
<p>I love comics so I will write about them.</p>
<h2>Marvel</h2>
<p>I will now discuss Marvel characters.</p>
<h3>Hulk</h3>
<h3>Spiderman</h3>
<h3>Ironman</h3>
<h2>DC</h2>
<p>How about DC characters?</p>
<h3>Wonder Woman</h3>
<h3>Superman</h3>
<h3>Batman</h3>
Insert cell
page = `<h1>Comics</h1>
<p>I love comics so I will write about them.</p>
<h2>Marvel</h2>
<p>I will now discuss Marvel characters.</p>
<h3>Hulk</h3>
<h3>Spiderman</h3>
<h3>Ironman</h3>
<h2>DC</h2>
<p>How about DC characters?</p>
<h3>Wonder Woman</h3>
<h3>Superman</h3>
<h3>Batman</h3>`
Insert cell
{
const $ = cheerio.load(page)
const headers = $("h3")
const result = []
for(let i = 0; i < 6; i = i + 1){
const header = headers.eq(i)
const text = header.text()
result.push(text)
}
return result
}
Insert cell
Insert cell
cheerio = require('https://bundle.run/cheerio@1.0.0-rc.2')
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more