Files
freestuff/steam.fish
2025-12-28 03:50:15 +01:00

39 lines
758 B
Fish

#!/bin/env fish
# Required applications:
# curl
# htmlq
# jq
# Query free games from steam
set -l offers (
curl -s 'https://store.steampowered.com/search?maxprice=free&specials=1' |
htmlq a.search_result_row
)
# Scrape the page
set -l posters (echo $offers | htmlq -a src img)
set -l links (echo $offers | htmlq -a href a)
set -l 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