Skip to content

Instantly share code, notes, and snippets.

@rnegron
Last active September 17, 2017 16:51
Show Gist options
  • Save rnegron/8a36eb2aa82ac8816a2fab6194986788 to your computer and use it in GitHub Desktop.
Save rnegron/8a36eb2aa82ac8816a2fab6194986788 to your computer and use it in GitHub Desktop.
Short Python script for parsing, numbering and printing the top 100 video games according to metacritic.com
import requests, re
from bs4 import BeautifulSoup as BS
META_URL = 'http://www.metacritic.com/browse/games/score/metascore/all/all/filtered?sort=des'
HEADERS = {'user-agent': 'Mozilla/5.0'}
r = requests.get(META_URL, headers=HEADERS)
soup = BS(r.text, 'html.parser')
for count, item in enumerate(soup.find_all('div', class_='product_item product_title'), 1):
print('{} {}'.format(count, re.sub(r'\(.*\)', '', item.a.string).strip()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment