Permalink
Browse files

Tidy up error checking in xfn scraping example

The local variable 'item' was not defined in the except blocks and the
program continued executing after encountering one of these exceptions.
  • Loading branch information...
1 parent 9fd0361 commit 1d4e940026bc10dd8144e403438f0d7a3d985bbd @gar gar committed Apr 8, 2012
Showing with 5 additions and 5 deletions.
  1. +5 −5 python_code/microformats__xfn_scrape.py
@@ -31,13 +31,13 @@
try:
page = urllib2.urlopen(URL)
-except urllib2.URLError:
- print 'Failed to fetch ' + item
-
-try:
soup = BeautifulSoup(page)
+except urllib2.URLError:
+ print 'Failed to fetch ' + URL
+ sys.exit()
except HTMLParser.HTMLParseError:
- print 'Failed to parse ' + item
+ print 'Failed to parse ' + URL
+ sys.exit()
anchorTags = soup.findAll('a')

0 comments on commit 1d4e940

Please sign in to comment.