Skip to content

Commit

Permalink
Merge pull request #5006 from chrisyamas/va_people
Browse files Browse the repository at this point in the history
VA people: new session id, fix phone and address handling
  • Loading branch information
NewAgeAirbender authored Aug 13, 2024
2 parents 694d9f1 + cdfe54a commit cd79b0c
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions scrapers_next/va/people.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ class PartialMember:


class MemberList(HtmlListPage):
session_id = "241" # 2024
# Can comment back in to re-run 2024 session
# session_id = "241" # 2024
session_id = "251" # 2025
source = f"https://lis.virginia.gov/{session_id}/mbr/MBR.HTM"

def process_item(self, item):
Expand Down Expand Up @@ -125,21 +127,27 @@ def get_offices(self, person):
else:
address.append(text.strip())

# Remove empty ones that only contain punctuation i.e ","
address = [x for x in address if len(x.strip()) > 2]

# the first contact block is capital
if i == 1:
office_obj = person.capitol_office
if phone:
office_obj.voice = phone
if address:
office_obj.address = "; ".join(address)

else:
office_obj = person.district_office
if phone:
if phone == person.capitol_office.voice:
office_obj.voice = ""
else:
office_obj.voice = phone
if address:
office_obj.address = "; ".join(address)

office_obj.address = "; ".join(address)
if phone:
# making sure we don't add the same phone number for district and capitol offices
if i != 1:
office_obj.voice = phone
else:
if phone == person.capitol_office.voice:
office_obj.voice = ""
if email:
person.email = email

Expand Down

0 comments on commit cd79b0c

Please sign in to comment.