Published
Edited
Mar 23, 2019
1 fork
Importers
42 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
fetch('https://www.rottentomatoes.com/m/mean_girls/')
Insert cell
Insert cell
soFetch('https://www.rottentomatoes.com/m/mean_girls/')
Insert cell
{
const res = await soFetch('https://www.rottentomatoes.com/m/mean_girls/');
const source = await res.text();
const dom = html`${source}`;
return dom.querySelector('#tomato_meter_link').textContent.trim();
}
Insert cell
Insert cell
Insert cell
{
const res = await soFetch('https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml');
const source = await res.text();
const dom = html`${source}`;
const articles = [...dom.querySelectorAll('item')].slice(0, 5); // [...x] converts x to an array
const bullets = articles.map((article) => {
const title = article.querySelector('title').textContent;
const url = article.querySelector('guid').textContent;
const byline = article.querySelector('dc\\:creator').textContent;
const time = (new Date(article.querySelector('pubDate').textContent)).toLocaleTimeString();
return `* [${title}](${url})\n * _${byline}_, ${time}`
});
return md`${bullets.join('\n')}`;
}
Insert cell
Insert cell
Insert cell
soFetch = function soFetch(url) {
return fetch(`https://sofetch.glitch.me/${encodeURI(url)}`);
}
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