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

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