Skip to content

Commit

Permalink
Merge pull request #5056 from alexobaseki/add-chamber-bill-scrapers
Browse files Browse the repository at this point in the history
MD & WY: add chamber to bill scrapers add_sponsorships()
  • Loading branch information
alexobaseki authored Oct 18, 2024
2 parents 6a9f25a + 39d50e4 commit 8d87b93
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 11 deletions.
33 changes: 27 additions & 6 deletions scrapers/md/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,18 @@ def scrape_bill_subjects(self, bill, page):
bill.add_subject(row[0])

def scrape_bill_sponsors(self, bill, page):
sponsors_title = "".join(
page.xpath(
'//dt[contains(text(), "Sponsored by")]/following-sibling::dd[1]/text()'
)
)
if "Delegate" in sponsors_title:
chamber = "lower"
elif "Senator" in sponsors_title:
chamber = "upper"
else:
chamber = None

sponsors = page.xpath(
'//dt[contains(text(), "Sponsored by")]/following-sibling::dd[1]/a'
)
Expand All @@ -363,12 +375,21 @@ def scrape_bill_sponsors(self, bill, page):
# sponsor the list is done
# (e.g. http://mgaleg.maryland.gov/mgawebsite/Legislation/Details/sb0125?ys=2021RS)
break
bill.add_sponsorship(
sponsor,
sponsor_type,
primary=sponsor_type == "primary",
entity_type=entity_type,
)
if chamber:
bill.add_sponsorship(
sponsor,
sponsor_type,
primary=sponsor_type == "primary",
entity_type=entity_type,
chamber=chamber,
)
else:
bill.add_sponsorship(
sponsor,
sponsor_type,
primary=sponsor_type == "primary",
entity_type=entity_type,
)

def scrape_bill(self, chamber, session, url):
html = self.get(url).content
Expand Down
24 changes: 19 additions & 5 deletions scrapers/wy/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,26 @@ def scrape_bill(self, bill_num, session):
for sponsor in bill_json["sponsors"]:
status = "primary" if sponsor["primarySponsor"] else "cosponsor"
sponsor_type = "person" if sponsor["sponsorTitle"] else "organization"
bill.add_sponsorship(
name=sponsor["name"],
classification=status,
entity_type=sponsor_type,
primary=sponsor["primarySponsor"],
chamber = (
"lower"
if sponsor["house"] == "H"
else ("upper" if sponsor["house"] == "S" else None)
)
if chamber:
bill.add_sponsorship(
name=sponsor["name"],
classification=status,
entity_type=sponsor_type,
primary=sponsor["primarySponsor"],
chamber=chamber,
)
else:
bill.add_sponsorship(
name=sponsor["name"],
classification=status,
entity_type=sponsor_type,
primary=sponsor["primarySponsor"],
)

if bill_json["summary"]:
bill.add_abstract(note="summary", abstract=bill_json["summary"])
Expand Down

0 comments on commit 8d87b93

Please sign in to comment.