Public
Edited
Feb 21, 2023
Insert cell
d3 = require("d3@6")
Insert cell
import { soFetch } from '@alecglassford/so-fetch'
Insert cell
import {Table} from "@observablehq/table"
Insert cell
async function scrapeTableData(url) {
const response = await soFetch(url);
const text = await response.text();
//const domparser = new DOMParser();
//const dom = domparser.parseFromString(text, "text/html");
const dom = html`${text}`;
const tables = await dom.querySelectorAll('table');
if (tables.length <= 0) {
throw new Error('Could not find any tables.');
}
const tablesLen = tables.length;

const tablesData = [];
for (let i = 0; i < tablesLen; i++) {
let tableEl = tables[i];

tablesData.push(tableEl);
}
return tablesData;
}
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