Created
December 7, 2020 12:11
-
-
Save mobeigi/7c6bd81d32c5cc975e6f5ad055aed8f7 to your computer and use it in GitHub Desktop.
Cyberpunk 2077 GoG Game Price Scraper
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 mechanicalsoup | |
import json | |
URL = 'https://menu.gog.com/v1/store/configuration?locale=en-US¤cy=USD&country=' | |
country_codes = ['AR','AU','AT','BS','BE','BO','BR','CA','CL','CN','CO','CR','HR','CU','CZ','DK','DO','EC','EG','SV','FI','FR','DE','GR','GT','HN','HK','IN','IE','IL','IT','JM','JP','LU','MX','MA','NL','NZ','NI','NG','NO','PY','PE','PL','PT','PR','RU','SA','ZA','ES','SE','CH','TW','TR','UK','US','UY','VE','SD','II','AF','AL','DZ','AO','AG','AW','AZ','BH','BD','BB','BY','BZ','BM','BT','BW','VG','BN','BG','BF','MM','BI','CM','CV','KY','KM','CG','CY','YE','DJ','DM','GQ','EE','FJ','GA','GM','GH','GD','GN','GW','GY','HT','HU','IS','ID','IR','CI','JO','KE','KW','KP','KG','LA','LV','LB','LR','LI','LT','MG','MY','ML','MT','MR','MN','MC','MZ','NP','AN','NE','OM','PK','PA','PH','QA','RO','KN','LC','VC','WS','SN','SG','SB','SZ','SY','TH','TT','TN','UA','AE','VN','YU','ZW','ZR','ET','KV','AX','AS','AD','AI','AQ','AM','BJ','BA','BV','IO','KH','CF','TD','CX','CC','CD','CK','ER','FK','FO','GF','PF','TF','GE','GI','GL','GP','GU','GG','HM','VA','IQ','IM','JE','KZ','KI','KR','LS','LY','MO','MK','MW','MV','MH','MQ','MU','YT','FM','MD','ME','MS','NA','NR','NC','NU','NF','MP','PW','PS','PG','PN','RE','RW','BL','SH','MF','PM','SM','ST','RS','SC','SL','SK','SI','SO','GS','SR','SJ','TJ','TZ','TL','TG','TK','TO','TM','TC','TV','UG','UM','UZ','VU','VI','WF','EH','ZM','LK'] | |
browser = mechanicalsoup.StatefulBrowser() | |
browser.set_user_agent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36') | |
for country_code in country_codes: | |
page = browser.get(URL + country_code) | |
if page.status_code != 200: | |
continue | |
price = page.json()["cyberpunk_list"]["products"][0]["price"]["amount"] | |
print(f'{country_code}: {price} USD') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Russia is king 🇷🇺