Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge remote-tracking branch 'origin/master'

  • Loading branch information...
commit d7b81ec24005a0d4a96e09c8a00cbe7ed0d28bd4 2 parents 9f8b3a2 + 9381f2c
@jamesturk jamesturk authored
Showing with 7 additions and 4 deletions.
  1. +1 −1  openstates/co/__init__.py
  2. +6 −3 openstates/co/legislators.py
View
2  openstates/co/__init__.py
@@ -14,7 +14,7 @@
{'name': '2011-2012',
'sessions': ['2011A', '2012A', '2012B'],
'start_year': 2011, 'end_year': 2012},
- {'name': '2011-2012',
+ {'name': '2013-2014',
'sessions': ['2013A'],
'start_year': 2013, 'end_year': 2014},
],
View
9 openstates/co/legislators.py
@@ -75,6 +75,7 @@ def parse_homepage( self, hp_url ):
pass
infoblock = page.xpath("//center")
info = infoblock[0].text_content()
+
number = re.findall("(\d{3})(-|\))?(\d{3})-(\d{4})", info)
if len(number) > 0:
number = number[0]
@@ -102,6 +103,8 @@ def process_person( self, p_url ):
with self.urlopen(p_url) as html:
page = lxml.html.fromstring(html)
+ page.make_links_absolute(p_url)
+
info = page.xpath( '//table/tr' )[1]
tds = {
"name" : 0,
@@ -119,11 +122,11 @@ def process_person( self, p_url ):
urls = page.xpath( '//a' )
ret['photo_url'] = ""
+ home_page = page.xpath("//a[contains(text(), 'Home Page')]")
- if len(urls) > 0:
- home_page = urls[0]
+ if home_page != []:
+ home_page = home_page[0]
ret['homepage'] = home_page.attrib['href'].strip()
- # home_page.attrib['href']
homepage = self.parse_homepage(
home_page.attrib['href'].strip() )
Please sign in to comment.
Something went wrong with that request. Please try again.