Permalink
Browse files

UT: handle missing special sessions, add 6th special session check

Signed-off-by: Sunlight Labs <git@sunlightlabs.com>
  • Loading branch information...
1 parent fdc4a9c commit e04c1dd75cda608651b9beb37469420d6aad232e @mikejs mikejs committed with Sunlight Labs Mar 30, 2009
Showing with 8 additions and 2 deletions.
  1. +8 −2 scripts/ut/get_legislation.py
@@ -21,7 +21,13 @@ def scrape_session(self, chamber, year):
bill_list_url = "http://www.le.state.ut.us/~%s/bills.htm" % year
print bill_list_url
- base_bill_list = BeautifulSoup(urllib2.urlopen(bill_list_url).read())
+
+ try:
+ base_bill_list = BeautifulSoup(urllib2.urlopen(bill_list_url).read())
+ except:
+ # this session doesn't exist for this year
+ return
+
bill_list_link_re = re.compile('.*%s\d+ht.htm$' % bill_abbr)
for link in base_bill_list.findAll('a', href=bill_list_link_re):
@@ -70,7 +76,7 @@ def scrape_bills(self, chamber, year):
if int(year) < 1997 or int(year) > dt.date.today().year:
raise NoDataForYear(year)
- for special in ["", "S1", "S2", "S3", "S4", "S5"]:
+ for special in ["", "S1", "S2", "S3", "S4", "S5", "S6"]:
self.scrape_session(chamber, year + special)
if __name__ == '__main__':

0 comments on commit e04c1dd

Please sign in to comment.