mul14
5/19/2016 - 4:51 AM

Checks Origin's on the House page for free games.

Checks Origin's on the House page for free games.

import requests
import bs4
from termcolor import colored

root_url = 'https://www.origin.com/en-gb/store/free-games/on-the-house'

def getFreeGames():
  try:
    response = requests.get(root_url)
    soup = bs4.BeautifulSoup(response.text)
    return [a.attrs.get('data-title') for a in soup.select('div.packart')]
  except requests.exceptions.ConnectionError:
    print colored('No internet connection available', 'red')
    return ""


def main():
  print('Currently free games on Origin: ')
  gamesFree = getFreeGames()

  for game in gamesFree:
    print colored(game.title(), 'green')

if __name__ == '__main__':
    main()