Skip to content

Instantly share code, notes, and snippets.

@unbracketed
Created January 24, 2010 03:53
Show Gist options
  • Save unbracketed/284995 to your computer and use it in GitHub Desktop.
Save unbracketed/284995 to your computer and use it in GitHub Desktop.
from BeautifulSoup import BeautifulSoup
from urllib import urlopen
url = "http://www.radioparadise.com/content.php?name=Playlist"
soup = BeautifulSoup(urlopen(url))
playlist_table = soup.findAll('table')[2]
track_rows = playlist_table.findAll('tr', attrs={'class':['shade', 'noshade']})
f = open('radioparadise_playlist.txt', 'w')
for row in track_rows:
td = row.findAll('td')[1]
a = td.find('a')
f.write('Artist: %s\n' % a.contents[0])
f.write('Song: %s\n' % a.contents[2])
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment