Skip to content

Instantly share code, notes, and snippets.

@joostrijneveld
Last active September 26, 2016 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joostrijneveld/063e7ddb80942067836a8c1be694b8e7 to your computer and use it in GitHub Desktop.
Save joostrijneveld/063e7ddb80942067836a8c1be694b8e7 to your computer and use it in GitHub Desktop.
Scrape whatever was last played on 3FM (in the current hour)
#! /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