Created
November 30, 2014 15:02
-
-
Save SliceOLife/fbe8b626b4a63de2e705 to your computer and use it in GitHub Desktop.
Finds the latest Origin on the House game and displays it.
This file contains hidden or 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
| from bottle import route, run | |
| import requests | |
| import bs4 | |
| root_url = 'https://www.origin.com/en-gb/store/free-games/on-the-house' | |
| def getFreeGames(): | |
| response = requests.get(root_url) | |
| soup = bs4.BeautifulSoup(response.text) | |
| return [a.attrs.get('data-title') for a in soup.select('div.packart')] | |
| @route('/free/<service>') | |
| def free_games(service): | |
| if service == "origin": | |
| return { "success" : True, "games" : getFreeGames() } | |
| else: | |
| return { "success" : False, "games" : "none", "error" : "this service isn't available (yet)" } | |
| run(host='localhost', port=8080, debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment