shot-scraper
shot-scraper copied to clipboard
Idea: JavaScript macros in the YAML file
This is just a harebrained idea at the moment: what if the YAML could define JavaScript that could be applied to all of the shots in the file, with customizations for each shot?
Something like this:
macros:
- javascript: |
Array.from(
document.querySelectorAll(
ShotScraper.inputs.toRemove
)
).forEach(el => el.style.display='none')
shots:
- url: https://site-one.com/
output: one.png
inputs:
toRemove: "#ad,#footer"
- url: https://site-two.com/
output: two.png
inputs:
toRemove: "#adbanner"
This could even be extended as a way to support annotations:
- #9
Named macros could be defined in a separate file and then that file name passed to the multi
command as an option.
shot-scraper multi shots.yaml --macro macros.yaml
Partly inspired by thinking about:
- https://github.com/palewire/news-homepages/issues/4
We're starting to build out our usage of shot-scraper
and could really use the ability to define macros for usage later. Not so much the inputs
functionality, just predefined functions would be enough.
My Python is rusty, but I'd be happy to try and PR this without inputs
if you're receptive