Skip to content

Commit

Permalink
Merge pull request #5104 from openstates/ok-events-fix-pdf-404s
Browse files Browse the repository at this point in the history
OK events: swallow exceptions for 404s on agenda PDFs
  • Loading branch information
jessemortenson authored Nov 29, 2024
2 parents 5dc3ee1 + 56b5c86 commit 61979ca
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions scrapers/ok/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from openstates.exceptions import EmptyScrape

from utils.events import match_coordinates
from scrapelib import HTTPError
from spatula import PdfPage, URL

bills_re = re.compile(
Expand All @@ -18,6 +19,13 @@


class Agenda(PdfPage):
def process_error_response(self, exception):
# OK has some known 404s for PDFs, so swallow those exceptions
if isinstance(exception, HTTPError):
self.logger.warning(f"Skipped PDF download due to to HTTPError {exception}")
else:
raise exception

def process_page(self):
# Find all bill ids
bills = bills_re.findall(self.text)
Expand Down

0 comments on commit 61979ca

Please sign in to comment.