#!/bin/fish # Required applications: # curl # htmlq # jq # Query free games from steam set offers ( curl -s 'https://store.steampowered.com/search?maxprice=free&specials=1' | htmlq a.search_result_row ) # Scrape the page set posters (echo $offers | htmlq -a src img) set links (echo $offers | htmlq -a href a) set offers (echo $offers | htmlq -t span.title) # Serialize data into JSON begin echo "[" for i in (seq (count $offers)) echo -n "{ \"link\": \"$links[$i]\", \"name\": \"$offers[$i]\", \"poster\": \"$posters[$i]\" }" if [ $i -eq (count $offers) ] echo "" else echo "," end end echo "]" end | jq