Skip to content

Commit

Permalink
US: Bills: Fix for vote with missing date" (#5176)
Browse files Browse the repository at this point in the history
  • Loading branch information
showerst authored Jan 3, 2025
1 parent 6e4ef67 commit 8e67de1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scrapers/usa/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,16 +620,21 @@ def scrape_votes(self, bill, xml):
content = requests.get(url).content
vote_xml = lxml.html.fromstring(content)
if chamber.lower() == "senate":
vote = self.scrape_senate_votes(bill, vote_xml, url)
vote = self.scrape_senate_votes(vote_xml, url)
elif chamber.lower() == "house":
vote = self.scrape_house_votes(bill, vote_xml, url)
yield vote
except (requests.exceptions.HTTPError, lxml.etree.XMLSyntaxError):
self.info(f"Error fetching {url}, skipping (used requests, no retries)")
return

def scrape_senate_votes(self, bill, page, url):
def scrape_senate_votes(self, page, url):
if not page.xpath("//roll_call_vote/vote_date/text()"):
self.error(f"Unable to parse vote date in {url}")
return

vote_date = page.xpath("//roll_call_vote/vote_date/text()")[0].strip()

when = self._TZ.localize(
datetime.datetime.strptime(vote_date, "%B %d, %Y, %H:%M %p")
)
Expand Down

0 comments on commit 8e67de1

Please sign in to comment.