Last active
August 29, 2015 14:07
-
-
Save CyberShadow/7ce38d02fdd992e62e00 to your computer and use it in GitHub Desktop.
Steam price fetcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
if _%1_==__ goto :eof | |
set URL=%~1 | |
if _%URL:~0,29%_==_http://store.steampowered.com_ goto urlok | |
goto next | |
:urlok | |
call :curl %1 store | |
:: TITLE | |
cat store.html ^ | |
| grep -oE ^ | |
-e "<title>.*</title>" ^ | |
| sed ^ | |
-e "s#<title>\(.*\) on Steam</title>#\1 - #g" ^ | |
-e "s#<title>\(.*\)</title>#\1 - #g" ^ | |
> output.html | |
:: PRICE | |
cat store.html ^ | |
| sed ^ | |
-e ^"s/^<div class=\^"discount_original_price\^"^>[^^^<]*^<\/div^>//g^" ^ | |
-e ^"s/Games Under .*/Price not found/g^" ^ | |
-e s/{.*}},$//g ^ | |
| grep -oE ^ | |
-e "$[^/<]*( USD)?" ^ | |
-e "£[^<]+" ^ | |
-e "[0-9,]+€" ^ | |
-e "Price not found" ^ | |
-e "This item is currently unavailable in your region" ^ | |
| sed ^ | |
-e "s/This item is currently unavailable in your region/This item is currently unavailable in my region :(/g" ^ | |
| head.exe -n 1 ^ | |
>> output.html | |
:: REGION LOCK | |
cat store.html ^ | |
| grep -oE ^ | |
-e "Purchases made in .* (playable in|can only be added|will only receive the) .*." ^ | |
| head.exe -n 1 ^ | |
| sed ^ | |
-e "s/..*/ [REGION LOCK] /g" ^ | |
>> output.html | |
:: RECOMMENDATIONS | |
cat store.html ^ | |
| tr "\n" " " ^ | |
| grep -oP ^ | |
-e "<div class=\"recommendation_area_content\">\s*<div class=\"quote quote_serif\">.*?<div" ^ | |
| sed ^ | |
-e ^"s#quote_serif\^"^>\s*#\0\^“#g^" ^ | |
-e ^"s#\s*^<div$#\^”#g^" ^ | |
-e ^"s#\s*^<br /^>#\^”\n#g^" ^ | |
| head.exe -n 1 ^ | |
>> output.html | |
cat store.html ^ | |
| grep -oE ^ | |
-e ^"^<a class=\^"recommendation_btn lighter\^" href=\^"http://steamcommunity\.com/.*/recommended/^" ^ | |
| sed ^ | |
-e ^"s#.*href=\^"\(http://steamcommunity.com/.*/\)recommended/.*#\1#g^" ^ | |
| head.exe -n 1 ^ | |
> recommenders.txt | |
if exist recommend_profile.html del recommend_profile.html | |
for /F %%a in (recommenders.txt) do call :curl %%a recommend_profile | |
if not exist recommend_profile.html goto no_recommender | |
cat recommend_profile.html ^ | |
| grep -oE ^ | |
-e "<title>.*</title>" ^ | |
| sed ^ | |
-e ^"s#^<title^>Steam Community :: \(.*\)^</title^>#-- \1#g^" ^ | |
>> output.html | |
:no_recommender | |
:: REDIRECT | |
cat store.txt ^ | |
| grep -oE ^ | |
-e "^< Location: .*$" ^ | |
| sed ^ | |
-e "s#< Location: \(.*\)#No such page (redirect to \\1)#g" ^ | |
>> output.html | |
:: OUTPUT | |
cat output.html ^ | |
| lynx -stdin -dump -width 400 -assume_charset=utf8 | |
:: NEXT PARAM | |
:next | |
call %0 %2 %3 %4 %5 %6 %7 %8 %9 | |
goto :eof | |
:curl | |
curl -v --silent -b cookies.txt "%1" > %2.html 2> %2.txt | |
if errorlevel 1 echo curl error & exit 1 | |
goto :eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment