Initial commit
This commit is contained in:
38
steam.fish
Normal file
38
steam.fish
Normal file
@ -0,0 +1,38 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user