Last active
September 17, 2017 16:51
-
-
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
This file contains 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, 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