Skip to content

Instantly share code, notes, and snippets.

@aborruso
Created March 16, 2024 08:36
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 aborruso/2599f282a4f122f6cd292f9ed913228d to your computer and use it in GitHub Desktop.
Save aborruso/2599f282a4f122f6cd292f9ed913228d to your computer and use it in GitHub Desktop.
### requisiti ###
#
# yq https://github.com/kislyuk/yq
# scrape-cli https://github.com/aborruso/scrape-cli
# mlr https://github.com/johnkerl/miller
#
### requisiti ###
# scarica la lista dei film a Palermo
curl -kL "https://www.mymovies.it/cinema/palermo/" | \
# estrai il div che contiene il voto medio e il successivo
scrape -be '//span[contains(@class, "mm-text-white")] | //div[div[span[contains(@class, "mm-text-white")]]]/following::div[1]' | \
# converti in JSON e estrai voto, titolo e URL
xq -c '[[.html.body.span[].span.strong],[.html.body.div[].div[1].a["#text"]],[.html.body.div[].div[1].a["@href"]]]|transpose[]|{voto:.[0],titolo:.[1],URL:.[2]}' | \
# converti in CSV e ordina per voto decrescente
mlr --j2c put '$voto=fmtnum(float($voto), "%.2f")' then sort -nr voto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment