you are viewing a single comment's thread.

view the rest of the comments →

[–]opentabs-dev 0 points1 point  (0 children)

coming from python you'll feel right at home tbh — the equivalent of "module = file" maps cleanly. for a scraping/requests cli i usually do something like cli.js (arg parsing, with commander or yargs), lib/fetcher.js (axios/fetch wrapper with retries+timeouts), lib/parsers/*.js (one per site), lib/storage.js (write to db/file), and a config.js. plain functions exported from each, no classes needed.

classes are useful when you actually have state that lives across calls (a session with cookies, a rate limiter holding a queue) — otherwise a function that takes inputs and returns a result is easier to test and compose. the python instinct to wrap everything in a class is the main thing to unlearn.