Published
Edited
Dec 1, 2021
1 star
Insert cell
Insert cell
page = FileAttachment("List of presidents of the United States - Wikipedia.htm").text()
Insert cell
data = {
const $ = cheerio.load(page)
const table = $("table").eq(1)
const rows = table.find("tr")
const result = []
for(let i = 1; i < rows.length; i = i + 1){
const row = rows.eq(i)
const cells = row.find("td")
const cell = cells.eq(1)
const image = cell.find("img")
const src = image.attr("src")
result.push(src)
}
return result.filter(d => d != undefined)
}
Insert cell
table = {
let table = `<table>`
for(let i = 0; i < data.length; i = i + 1){
table = table + ` <tr> <td> <img src = "https:${data[i]}" /> </td> </tr> `
}
table = table + `</table>`
return table
}
Insert cell
html`${table}`
Insert cell
Insert cell
Insert cell
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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