I had a recent realizing that Deno is actually an amazing tool for scripts and webscraping. It runs TS natively so I can take advantage of TypeScript's amazing type system when interacting with complex APIs. Being able to import libraries from a url also makes it a breeze to use any libraries (I've yet to run into a node module that Deno's std/node library wasn't able to polyfill).
I can basically write a .ts file anywhere and run it from the CLI with deno. Definitely prefer it over python at this point
I use Deno for linting, having a binary there instead of using NPM to get a linter is a different level of simple. I like your idea, though I rarely use js for scripts I'm sure it'll come in handy.
I haven't done something like that yet, but I'm sure there would be. Most webscraping libraries have good `@types` definitions now though which really comes in handy for at least using the tools
You can probably try it in a few minutes if you already have Deno installed. Make a new file. Here's a quick example script
```ts
/* run with `deno run --allow-net demo.ts` */
import { DOMParser } from 'https://deno.land/x/deno_dom/deno-dom-wasm.ts';
const API_URL = 'https://subsidytracker.goodjobsfirst.org/parent/tesla-inc';
const main = async (args: string[]) => {
const resp = await fetch(API_URL);
const text = await resp.text();
const html = new DOMParser().parseFromString(text, 'text/html');
console.log(
'Tesla subsidies:',
[
...html.querySelectorAll('table:first-of-type > tbody:first-of-type > tr')
].map(tr => {
const [name, value] = [...tr.querySelectorAll('td')];
return {
name: name.textContent,
value: value.textContent
};
})
);
};
main(Deno.args);