Skip to content

Instantly share code, notes, and snippets.

@einstein95
Last active August 19, 2020 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save einstein95/821e76b2c66d775f7f14afbdbc18c538 to your computer and use it in GitHub Desktop.
Save einstein95/821e76b2c66d775f7f14afbdbc18c538 to your computer and use it in GitHub Desktop.
Get game URLs from Kongregate
#!/usr/bin/python3
import re
import requests
import uuid
from sys import argv, exit
from urllib.parse import unquote
PROTOCOL = 'https:'
if 'www.kongregate.com' not in argv[1]:
exit('no')
r = requests.get(argv[1])
iframe_url, = re.findall(r"iframe_url\":(?:\'|\")([^'\"]+)", r.text)
if len(re.findall('channel_id', r.text)) > 6:
r = requests.get(iframe_url+str(uuid.uuid4()))
else:
print(iframe_url)
exit()
game_url = re.findall(r'game_swf":"([^"]+)', r.text)
if not game_url:
if 'unity_265x250.swf' in r.text:
game_url = re.findall(r'unityObject.embedUnity\(\\"kongregateUnityDiv\\", \\"([^\\]+)', r.text)
else:
game_url = re.findall(r'swf_location = "([^"]+)', r.text)
print(PROTOCOL+unquote(game_url[0]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment