Forked from Granitosaurus/steam_game_linkinator
Last active
September 29, 2017 22:26
-
-
Save Almenon/9db1aaea171e88c720e8c8095ca0308a to your computer and use it in GitHub Desktop.
converts a list of games into linked items with reviews.
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
import requests | |
from parsel import Selector | |
# $("div.dd-image-box-caption").toArray().forEach((div)=>{console.log(div.textContent.trim())}); | |
data = """Sam & Max: Season 1 | |
Sam & Max: Season 2 | |
Puzzle Agent 1 | |
Puzzle Agent 2 | |
Bone - Episode 1 & Episode 2 | |
Hector: Badge of Carnage | |
Telltale Texas Hold'em | |
Poker Night at the Inventory | |
The Walking Dead - Season 1 | |
The Walking Dead: Michonne | |
Tales from the Borderlands | |
The Walking Dead - Season 2 | |
Game of Thrones | |
The Walking Dead: A New Frontier 50% OFF Humble Store Coupon | |
More in 6 days 16 hours | |
Batman - The Telltale Series | |
Minecraft: Story Mode | |
Minecraft: Story Mode - Adventure Pass | |
""" | |
print("**All games, sorted by review:**") | |
print("") | |
items = data.splitlines() | |
items = [i.split(' (')[0] for i in items if i] | |
data = [] | |
for item in items: | |
# Search string on steam, get first result | |
resp = requests.get('http://store.steampowered.com/search/?term={}'.format(item)) | |
first = Selector(text=resp.text).css('a.search_result_row::attr(href)').extract_first() | |
if(first is None): continue | |
first = first.split('?')[0] | |
# Also get rating | |
cookies = { 'birthtime': '283993201', 'mature_content': '1' } | |
resp = requests.get(first, cookies=cookies) | |
rating = Selector(text=resp.text).css("span.game_review_summary::attr(data-store-tooltip)").re('\d+%') | |
rating = rating[1] if rating else '~%' | |
# print markdown'ed string | |
data.append('[{}]({}) - {}'.format(item, first, rating)) | |
dataWithReviews = filter(lambda x: x.find('- ~%') == -1,data) | |
dataWithoutReviews = filter(lambda x: x.find('- ~%') > -1, data) | |
[print(line + '\n') for line in sorted(dataWithReviews, reverse=True, key=lambda line: int(line[-4:-1]) )] | |
[print(line + '\n') for line in dataWithoutReviews] | |
print(""" | |
------ | |
python code [here](https://gist.github.com/Almenon/9db1aaea171e88c720e8c8095ca0308a) | |
""") | |
# data = """Q.U.B.E.: Director's Cut | |
# Rituals | |
# Dangerous High School Girls In Trouble | |
# TIMEframe | |
# JumpJet Rex | |
# Potatoman Seeks the Troof | |
# Ballistick | |
# GRAV (early access) | |
# Team Indie | |
# Luna's Wandering Stars | |
# Rocketbirds: Hardboiled Chicken | |
# Chroma Squad | |
# Shutshimi | |
# Beat Hazard Ultra | |
# Ben Prunty - Color Sky (album) | |
# Hands-On Intro to Game Programming (book)""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment