Skip to content

Commit

Permalink
Added special sessions and scraper to TN
Browse files Browse the repository at this point in the history
  • Loading branch information
showerst committed Sep 14, 2016
1 parent 191d7c0 commit b5206b6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
14 changes: 13 additions & 1 deletion openstates/tn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,22 @@
'start_year': 2011, 'end_year': 2012},
{'name': '108', 'sessions': ['108'],
'start_year': 2013, 'end_year': 2014},
{'name': '109', 'sessions': ['109'],
{'name': '109', 'sessions': ['109','109s1','109s2'],
'start_year': 2015, 'end_year': 2016},
],
session_details={
'109s2': {
'type': 'special',
'start_date': datetime.date(2016, 9, 12),
'end_date': datetime.date(2016, 9, 14),
'display_name': '109th Second Extraordinary Session (September 2016)',
'_scraped_name': '2nd Extraordinary Session (September 2016)'},
'109s1': {
'type': 'special',
'start_date': datetime.date(2016, 2, 1),
'end_date': datetime.date(2016, 2, 29),
'display_name': '109th First Extraordinary Session (February 2016)',
'_scraped_name': '1st Extraordinary Session (February 2015)'},
'109': {
'type': 'primary',
'display_name': '109th Regular Session (2015-2016)',
Expand Down
16 changes: 12 additions & 4 deletions openstates/tn/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,24 @@ class TNBillScraper(BillScraper):
def scrape(self, term, chambers):

#The index page gives us links to the paginated bill pages
index_page = 'http://wapp.capitol.tn.gov/apps/indexes/'
if self.metadata['session_details'][term]['type'] == 'special':
index_page = 'http://wapp.capitol.tn.gov/apps/indexes/SPSession1.aspx'
xpath = '//h4[text()="%s"]/following-sibling::table[1]/tbody/tr/td/a' % self.metadata['session_details'][term]['_scraped_name']
else:
index_page = 'http://wapp.capitol.tn.gov/apps/indexes/'
xpath = '//td[contains(@class,"webindex")]/a'

index_list_page = self.get(index_page).text

index_list_page = lxml.html.fromstring(index_list_page)
index_list_page.make_links_absolute(index_page)

for bill_listing in index_list_page.xpath('//td[contains(@class,"webindex")]/a'):

for bill_listing in index_list_page.xpath(xpath):
bill_listing = bill_listing.attrib['href']

bill_list_page = self.get(bill_listing).text

bill_list_page = lxml.html.fromstring(bill_list_page)
bill_list_page.make_links_absolute(bill_listing)

Expand Down

0 comments on commit b5206b6

Please sign in to comment.