Skip to content

Instantly share code, notes, and snippets.

@AbhinavMadahar
Created January 9, 2022 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AbhinavMadahar/f04cb4dd6c981930a0f441dd2229944a to your computer and use it in GitHub Desktop.
Save AbhinavMadahar/f04cb4dd6c981930a0f441dd2229944a to your computer and use it in GitHub Desktop.
19hz shows library
import { parse } from 'node-html-parser';
import fetch from 'node-fetch';
export default async (location) => {
try {
const page = await fetch(`https://19hz.info/eventlisting_${location}.php`);
const parsed = parse(await page.text());
const rows = parsed.querySelector('tbody').childNodes.slice(1).map(tr => tr.childNodes);
const shows = rows
.map(row => row.map(td => td.childNodes.reduce((prev, curr) => prev + curr.rawText, '')))
.map(show => ({
'Date/Time': show[0],
'Event Title @ Venue': show[1],
'Tags': show[2],
'Organizers': show[3],
'Links': show[4],
}));
return shows;
} catch (e) {
throw `Incorrect location provided: ${location}`;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment