Skip to content

Instantly share code, notes, and snippets.



Last active Dec 14, 2019
What would you like to do?
#!/usr/bin/env python3
# usage: aoty [year]
# This script collects all the albums of the year for Alf's awesome
# AOTY site and prints out the albums
# that appear on more than one Album of the Year list.
# You'll need beautifulsoup4 and requests to run this.
import sys
import datetime
import requests
from bs4 import BeautifulSoup
from collections import Counter
if len(sys.argv) > 1:
year = sys.argv[1]
year = str(
counter = Counter()
url = '' + year + '/'
while True:
html = requests.get(url).text
doc = BeautifulSoup(html, features="html.parser")
for li in doc.find_all('li'):
if li.get('itemtype') == '':
band, album = [a.text.strip() for a in li.find_all('a')]
s = '{} - {}'.format(band, album)
counter[s] += 1
next_url ='a[rel="next"]')
if len(next_url) > 0:
url = '' + next_url[0]['href']
for name, count in counter.most_common():
if count > 1:
print('{: >2} {}'.format(count, name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.