[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Librefm-commits] [1434] If we fail to scrape a page, wait and try again
From: |
Daniel Watkins |
Subject: |
[Librefm-commits] [1434] If we fail to scrape a page, wait and try again. |
Date: |
Sat, 09 May 2009 13:01:09 +0000 |
Revision: 1434
http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1434
Author: odd_bloke
Date: 2009-05-09 13:01:08 +0000 (Sat, 09 May 2009)
Log Message:
-----------
If we fail to scrape a page, wait and try again.
Modified Paths:
--------------
trunk/lastscrape/lastscrape.py
Modified: trunk/lastscrape/lastscrape.py
===================================================================
--- trunk/lastscrape/lastscrape.py 2009-05-09 12:56:39 UTC (rev 1433)
+++ trunk/lastscrape/lastscrape.py 2009-05-09 13:01:08 UTC (rev 1434)
@@ -11,7 +11,13 @@
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Librefm-commits] [1434] If we fail to scrape a page, wait and try again.,
Daniel Watkins <=