Last active
September 26, 2016 19:10
-
-
Save joostrijneveld/063e7ddb80942067836a8c1be694b8e7 to your computer and use it in GitHub Desktop.
Scrape whatever was last played on 3FM (in the current hour)
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
#! /bin/env python | |
from bs4 import BeautifulSoup | |
import requests | |
URL = "http://www.3fm.nl/welkliedjewasdat" | |
r = requests.get(URL) | |
r.encoding = 'utf-8' | |
soup = BeautifulSoup(r.text, 'lxml') | |
tracks = (soup.find('ul', {'class': 'track_list'}) | |
.find_all('li', recursive=False)) | |
for track in tracks: | |
time = track.find(attrs={'class': 'track_starttime'}).text | |
artist = track.find(attrs={'class': 'artist'}).text.upper() | |
track = track.find(attrs={'class': 'track'}).text.title() | |
print("[{}] {} - {}".format(time, artist, track)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment