Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import cheerio from "npm:cheerio";
export default async function mylittlescraper(req) {
console.log(req.params);
const sourceUrl = `https://ssb.ua.edu/pls/PROD/ua_bwckschd.p_disp_detail_sched?term_in=202340&crn_in=43971`;
let siteText = await fetch(sourceUrl);
const $ = cheerio.load(await siteText.text());
const $numclass = $("table.datadisplaytable:nth-child(16) > tbody:nth-child(2) > tr:nth-child(2) > td:nth-child(3)");
const numberOfSeats = $numclass.text();
let isOpen = false;
if (Number.parseInt(numberOfSeats) > 0) {
isOpen = true;
}
return Response.json({ open: isOpen });
}
abhudson3-tancrane.web.val.run
April 20, 2024