Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

phone fix

  • Loading branch information...
commit a2a7f7fb40a2798fef281f13c20c8d74d0051c05 1 parent 27e40c7
James Turk jamesturk authored
Showing with 46 additions and 20 deletions.
  1. +1 −1  legislators/legislators.csv
  2. +45 −19 legislators/update_legislators.py
2  legislators/legislators.csv
View
@@ -270,7 +270,7 @@
"Rep","John","","Hall","","","D","NY","19","1","M","202-225-5441","202-225-3289","http://johnhall.house.gov/","http://johnhall.house.gov/emailjohn.asp","","1217 Longworth House Office Building","H001039","69119","H6NY19144","412222","N00027888","P0-001-000016702-1","","http://www.opencongress.org/wiki/John_Hall","http://www.youtube.com/RepJohnHall","","","07/23/1948"
"Rep","Phil","G.","Hare","","","D","IL","17","1","M","202-225-5905","202-225-5396","http://hare.house.gov/","http://hare.house.gov/?sectionid=74&sectiontree=44,50,74","","428 Cannon House Office Building","H001040","66451","H6IL17155","412204","N00028234","P0-001-000016729-8","","http://www.opencongress.org/wiki/Phil_Hare","http://www.youtube.com/philhareil17","","","02/21/1949"
"Rep","Dean","","Heller","","","R","NV","2","1","M","202-225-6155","202-225-5679","http://heller.house.gov/","http://heller.house.gov/zipauth.shtml","","125 Cannon House Office Building","H001041","2291","H6NV02164","412218","N00027522","P0-001-000016730-4","DeanHeller","http://www.opencongress.org/wiki/Dean_Heller","http://www.youtube.com/CongressmanHeller","","","05/10/1960"
-"Rep","Mazie","K.","Hirono","","","D","HI","2","1","F","202 225-4906","202-225-4987","http://hirono.house.gov/","http://hirono.house.gov/IMA/issue_subscribe.htm","","1524 Longworth House Office Building","H001042","1677","H6HI02251","412200","N00028139","P0-001-000016731-3","maziehirono","http://www.opencongress.org/wiki/Mazie_Hirono","http://www.youtube.com/CongresswomanHirono","http://www.house.gov/apps/list/press/hi02_hirono/RSS.xml","","11/03/1947"
+"Rep","Mazie","K.","Hirono","","","D","HI","2","1","F","202-225-4906","202-225-4987","http://hirono.house.gov/","http://hirono.house.gov/IMA/issue_subscribe.htm","","1524 Longworth House Office Building","H001042","1677","H6HI02251","412200","N00028139","P0-001-000016731-3","maziehirono","http://www.opencongress.org/wiki/Mazie_Hirono","http://www.youtube.com/CongresswomanHirono","http://www.house.gov/apps/list/press/hi02_hirono/RSS.xml","","11/03/1947"
"Rep","Paul","W.","Hodes","","","D","NH","2","1","M","202-225-5206","202-225-2946","http://hodes.house.gov/","http://hodes.house.gov/contact.aspx","","1317 Longworth House Office Building","H001043","42473","H4NH02175","412220","N00027048","P0-001-000016704-9","PaulHodes","http://www.opencongress.org/wiki/Paul_Hodes","","","","03/21/1951"
"Rep","Deborah","","Halvorson","","Debbie","D","IL","11","1","F","202-225-3635","202-225-3521","http://halvorson.house.gov/","https://forms.house.gov/halvorson/contact-form.shtml","","1541 Longworth House Office Building","H001044","9531","H8IL11113","412279","N00029377","","","http://www.opencongress.org/wiki/Deborah_Halvorson","http://www.youtube.com/repdebbiehalvorson","","","03/01/1958"
"Rep","Gregg","","Harper","","","R","MS","3","1","M","202-225-5031","202-225-5797","http://harper.house.gov/","http://harper.house.gov/contact/","","307 Cannon House Office Building","H001045","101985","H8MS03067","412280","N00029632","","GreggHarper","http://www.opencongress.org/wiki/Gregg_Harper","http://www.youtube.com/congressmanharper","","","06/01/1956"
64 legislators/update_legislators.py
View
@@ -103,17 +103,8 @@ def add_legislator_from_pvs(self, official, bioguide_id):
# in_office
person['in_office'] = '1'
- #curleg = self.get_legislator(state=state, district=district,
- # in_office='1')
- #if curleg:
- # print 'Setting in_office=False on:', curleg
- # curleg['in_office'] = '0'
person['bioguide_id'] = bioguide_id
- # person['crp_id'] =
- # person['govtrack_id'] =
- # person['twitter_id'] =
- # person['congresspedia_url'] =
self.legislators[bioguide_id] = person
@@ -352,6 +343,35 @@ def standardize_file(csvfile):
l['birthdate'] = newdate
tbl.save_to(csvfile)
+# title
+# firstname
+# middlename
+# lastname
+# name_suffix
+# nickname
+# party
+# state
+# district
+# in_office
+# gender
+# phone
+# fax
+# website
+# webform
+# email
+# congress_office
+# bioguide_id
+# votesmart_id
+# fec_id
+# govtrack_id
+# crp_id
+# twitter_id
+# congresspedia_url
+# youtube_url
+# official_rss
+# senate_class
+# birthdate
+
def scrape_house(csvfile):
table = LegislatorTable(csvfile)
base_url = 'http://clerk.house.gov/member_info/mem_contact_info.html?statdis=%s%02d'
@@ -359,16 +379,22 @@ def scrape_house(csvfile):
url = base_url % (leg['state'], int(leg['district']))
data = urllib2.urlopen(url).read()
doc = lxml.html.fromstring(data)
- try:
- # district, addr, city, phone, (optional note about subcommittees)
- addr = doc.xpath('//div[@id="results"]/p/text()')[1]
- addr = addr.strip().replace('HOB', 'House Office Building')
- if addr != leg['congress_office']:
- leg['congress_office'] = addr
- print 'Updated', leg['firstname'], leg['lastname']
- except Exception as e:
- print 'encountered exception (%s) while processing %s %s' % (
- e, leg['firstname'], leg['lastname'])
+
+ # district, addr, city, phone, (optional note about subcommittees)
+ pieces = doc.xpath('//div[@id="results"]/p/text()')
+ addr = pieces[1]
+ addr = addr.strip().replace('HOB', 'House Office Building')
+ if addr != leg['congress_office']:
+ leg['congress_office'] = addr
+ print 'Updated', leg['firstname'], leg['lastname'], 'address'
+
+ # phone
+ phone = pieces[3][7:]
+ phone = phone.replace('(', '').replace(') ', '-')
+ if phone != leg['phone']:
+ leg['phone'] = phone
+ print 'Updated', leg['firstname'], leg['lastname'], 'phone'
+
table.save_to(csvfile)
def main():
Please sign in to comment.
Something went wrong with that request. Please try again.