Skip to content

Commit e965818

Browse files
authored
MN, CO Bills Fixes for broken dates
1 parent 00a9205 commit e965818

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

scrapers/co/bills.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class COBillScraper(Scraper, LXMLMixin):
4747
max_pages = 2
4848

4949
def scrape(self, chamber=None, session=None):
50+
# If you need to scrape an individual bill for testing
51+
# yield from self.scrape_bill("https://leg.colorado.gov/bills/HB26-1362", "2026")
52+
5053
# TODO: there's a better way to do this
5154
for i in self.jurisdiction.legislative_sessions:
5255
if i["identifier"] == session:
@@ -212,9 +215,12 @@ def scrape_documents(self, bill: Bill, page: lxml.html.HtmlElement):
212215

213216
def scrape_laws(self, bill: Bill, page: lxml.html.HtmlElement):
214217
for row in page.cssselect("div#bill-activity-session-laws tbody tr"):
215-
effective = dateutil.parser.parse(
216-
self.clean(row.xpath("td[1]/span"))
217-
).date()
218+
if self.clean(row.xpath("td[1]/span")):
219+
effective = dateutil.parser.parse(
220+
self.clean(row.xpath("td[1]/span"))
221+
).date()
222+
else:
223+
effective = None
218224
chapter = self.clean(row.xpath("td[2]/span"))
219225
title = self.clean(row.xpath("td[3]/span"))
220226
chapter = f"Chapter: {chapter} {title}"

scrapers/mn/bills.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,11 @@ def parse_inline_action_date(self, text):
458458
def parse_dates(self, datestr):
459459
# Fixing a typo in source data on following URL
460460
# https://www.revisor.mn.gov/bills/bill.php?b=House&f=HF2184&ssn=0&y=2025
461-
datestr = datestr.replace("/225", "/2025").replace("/226", "2026")
461+
datestr = (
462+
datestr.replace("/225", "/2025")
463+
.replace("/226", "2026")
464+
.replace("05/272026", "05/27/2026")
465+
)
462466
date_formats = ["%m/%d/%Y", "%m/%d/%y"]
463467
for fmt in date_formats:
464468
try:

0 commit comments

Comments
 (0)