Last active
May 19, 2016 04:51
-
-
Save SliceOLife/47ef1709f57ced5147d7 to your computer and use it in GitHub Desktop.
Checks Origin's on the House page for free games.
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
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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment