[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Librefm-commits] [1436] Move retrying logic further up, to catch more e
From: |
Daniel Watkins |
Subject: |
[Librefm-commits] [1436] Move retrying logic further up, to catch more errors. |
Date: |
Sat, 09 May 2009 13:06:58 +0000 |
Revision: 1436
http://svn.sv.gnu.org/viewvc/?view=rev&root=librefm&revision=1436
Author: odd_bloke
Date: 2009-05-09 13:06:58 +0000 (Sat, 09 May 2009)
Log Message:
-----------
Move retrying logic further up, to catch more errors.
Modified Paths:
--------------
trunk/lastscrape/lastscrape.py
Modified: trunk/lastscrape/lastscrape.py
===================================================================
--- trunk/lastscrape/lastscrape.py 2009-05-09 13:01:33 UTC (rev 1435)
+++ trunk/lastscrape/lastscrape.py 2009-05-09 13:06:58 UTC (rev 1436)
@@ -11,13 +11,8 @@
def parse_page(page):
"""Parse a page of recently listened tracks and return a list."""
- try:
- soup = BeautifulSoup(urllib2.urlopen(page),
- convertEntities=BeautifulSoup.HTML_ENTITIES)
- except:
- time.sleep(1)
- soup = BeautifulSoup(urllib2.urlopen(page),
- convertEntities=BeautifulSoup.HTML_ENTITIES)
+ 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
@@ -50,7 +45,11 @@
except:
num_pages = 1
for cur_page in range(1, num_pages + 1):
- tracks = parse_page(url + '?page=' + str(cur_page))
+ try:
+ tracks = parse_page(url + '?page=' + str(cur_page))
+ except:
+ time.sleep(1)
+ tracks = parse_page(url + '?page=' + str(cur_page))
for artist, track, timestamp in tracks:
yield (artist, track, timestamp)
if cur_page < num_pages:
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Librefm-commits] [1436] Move retrying logic further up, to catch more errors.,
Daniel Watkins <=