Skip to content

Commit

Permalink
Merge pull request #4916 from NewAgeAirbender/tn_bills
Browse files Browse the repository at this point in the history
TN: don't pull votes on related bill
  • Loading branch information
NewAgeAirbender authored Apr 11, 2024
2 parents d432809 + d3a2fd3 commit a433f2e
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions scrapers/tn/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,20 +271,18 @@ def scrape_bill(self, session, bill_url):
actions_from_table(bill, atable)

# votes
yield from self.scrape_vote_events(bill, page, bill_url)
yield from self.scrape_vote_events(bill, page, bill_url, primary_chamber)

bill.actions.sort(key=lambda a: a["date"])
yield bill

def scrape_vote_events(self, bill, page, link):
chamber_labels = (("lower", "lblHouseVoteData"), ("upper", "lblSenateVoteData"))
for chamber, element_id in chamber_labels:
raw_vote_data = page.xpath("//*[@id='{}']".format(element_id))[
0
].text_content()
votes = self.scrape_votes_for_chamber(chamber, raw_vote_data, bill, link)
for vote in votes:
yield vote
def scrape_vote_events(self, bill, page, link, chamber):
chamber_labels = {"lower": "lblHouseVoteData", "upper": "lblSenateVoteData"}
element_id = chamber_labels[chamber]
raw_vote_data = page.xpath(f"//*[@id='{element_id}']")[0].text_content()
votes = self.scrape_votes_for_chamber(chamber, raw_vote_data, bill, link)
for vote in votes:
yield vote

def scrape_votes_for_chamber(self, chamber, vote_data, bill, link):
raw_vote_data = re.split(r"\w+? by [\w ]+?\s+-", vote_data.strip())[1:]
Expand Down

0 comments on commit a433f2e

Please sign in to comment.