Skip to content

Instantly share code, notes, and snippets.

@SliceOLife
Created November 30, 2014 15:02
Show Gist options
  • Select an option

  • Save SliceOLife/fbe8b626b4a63de2e705 to your computer and use it in GitHub Desktop.

Select an option

Save SliceOLife/fbe8b626b4a63de2e705 to your computer and use it in GitHub Desktop.
Finds the latest Origin on the House game and displays it.
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