Skip to content

Commit

Permalink
Added 2016 WV special session and bill scraper changes to accommodate…
Browse files Browse the repository at this point in the history
… specials
  • Loading branch information
showerst committed May 19, 2016
1 parent 8b03cb5 commit 9264311
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
7 changes: 6 additions & 1 deletion openstates/wv/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
{'name': '2015-2016',
'start_year': 2015, 'end_year': 2016,
'sessions': ['2015', '2016'],
'sessions': ['2015', '2016', '20161S'],
}
],
'session_details': {
Expand All @@ -48,6 +48,11 @@
'2016': {'display_name': '2016 Regular Session',
'_scraped_name': '2016'
},
'20161S': {'display_name': '2016 First Special Session',
'_scraped_name': '2016',
'type':'special',
'_special_name': '1X'
},
},
'feature_flags': ['subjects', 'influenceexplorer'],
'_ignored_scraped_sessions': [
Expand Down
21 changes: 18 additions & 3 deletions openstates/wv/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,18 @@ def scrape(self, chamber, session):
orig = 's'

# scrape bills
url = ("http://www.legis.state.wv.us/Bill_Status/"
if (self.metadata['session_details'][session]['type'] == 'special'):
url = ("http://www.legis.state.wv.us/Bill_Status/"
"Bills_all_bills.cfm?year=%s&sessiontype=%s"
"&btype=bill&orig=%s"
% (self.metadata['session_details'][session]['_scraped_name'],
self.metadata['session_details'][session]['_special_name'],
orig))
else:
url = ("http://www.legis.state.wv.us/Bill_Status/"
"Bills_all_bills.cfm?year=%s&sessiontype=RS"
"&btype=bill&orig=%s" % (session, orig))

page = lxml.html.fromstring(self.get(url).text)
page.make_links_absolute(url)

Expand All @@ -67,8 +76,14 @@ def scrape(self, chamber, session):
link.attrib['href'])

# scrape resolutions
res_url = ("http://www.legis.state.wv.us/Bill_Status/res_list.cfm?"
"year=%s&sessiontype=rs&btype=res") % session
if (self.metadata['session_details'][session]['type'] == 'special'):
res_url = ("http://www.legis.state.wv.us/Bill_Status/res_list.cfm?year=%s&sessiontype=%s&btype=res"
% (self.metadata['session_details'][session]['_scraped_name'],
self.metadata['session_details'][session]['_special_name']))
else:
res_url = ("http://www.legis.state.wv.us/Bill_Status/res_list.cfm?year=%s&sessiontype=rs&btype=res"
% (self.metadata['session_details'][session]['_scraped_name']))

doc = lxml.html.fromstring(self.get(res_url).text)
doc.make_links_absolute(res_url)

Expand Down

0 comments on commit 9264311

Please sign in to comment.