We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 94c7e285 authored by Daniel Watkins's avatar Daniel Watkins

If we fail to scrape a page, wait and try again.

parent 0132f826
......@@ -11,7 +11,13 @@ sys.stdout = codecs.lookup('utf-8')[-1](sys.stdout)
def parse_page(page):
"""Parse a page of recently listened tracks and return a list."""
soup = BeautifulSoup(urllib2.urlopen(page), convertEntities=BeautifulSoup.HTML_ENTITIES)
try:
soup = BeautifulSoup(urllib2.urlopen(page),
convertEntities=BeautifulSoup.HTML_ENTITIES)
except:
time.sleep(1)
soup = BeautifulSoup(urllib2.urlopen(page),
convertEntities=BeautifulSoup.HTML_ENTITIES)
for row in soup.find('table', 'candyStriped tracklist').findAll('tr'):
artist, track, timestamp = parse_track(row)
# Tracks submitted before 2005 have no timestamp
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment