Skip to content

Instantly share code, notes, and snippets.

@AdriDevelopsThings
Created September 2, 2023 15:46
Show Gist options
  • Save AdriDevelopsThings/73f05c3eea1464de62ea6363484366e9 to your computer and use it in GitHub Desktop.
Save AdriDevelopsThings/73f05c3eea1464de62ea6363484366e9 to your computer and use it in GitHub Desktop.
Get all VBB lines from vbb.de
import { DOMParser } from "https://deno.land/x/deno_dom@v0.1.38/deno-dom-wasm.ts";
const url = "https://www.vbb.de/fahrinformation/zug-um-zug-mehr-schiene/{LINE}/"
async function checkLine(line: string) {
const response = await fetch(url.replace('{LINE}', line))
if (response.status == 200) {
const dom = new DOMParser().parseFromString(await response.text(), "text/html")
const headline = dom?.getElementById("content")!.getElementsByTagName("header")[0].getElementsByTagName("h1")[0].textContent.trim()
console.log(`${headline}`)
}
}
for (let re = 1; re < 20; re++) {
await checkLine(`re${re}`)
}
for (let rb=1; rb < 100; rb++) {
await checkLine(`rb${rb}`)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment