Public
Back
Version 8
4/22/2024
import cheerio from "npm:cheerio";
const DIAMOND_LEAGUE_EVENT_URL = "https://shanghai.diamondleague.com/programme-results/programme-results-shanghai/";
function normalizeURL(url: string) {
return url.startsWith("http://") || url.startsWith("https://")
? url
: "http://" + url;
}
async function fetchText(url: string, options?: any) {
const response = await fetch(normalizeURL(url), {
redirect: "follow",
...(options || {}),
});
return response.text();
}
export const webScrapeBytesNewsletter = async () => {
const html = await fetchText(DIAMOND_LEAGUE_EVENT_URL);
const $ = cheerio.load(html);
const $rows = $(".row");
console.log($rows);
return {
$rows,
};
};
webScrapeBytesNewsletter();
Updated: April 22, 2024