diff --git a/city_scrapers/spiders/atconj_County_Commission.py b/city_scrapers/spiders/atconj_County_Commission.py index 9f19266..94ab6f1 100644 --- a/city_scrapers/spiders/atconj_County_Commission.py +++ b/city_scrapers/spiders/atconj_County_Commission.py @@ -28,7 +28,8 @@ class AtconjCountyCommissionSpider(CityScrapersSpider): """ This website would return a 403 error if the request is made with the default headers. The headers below - are the ones that are needed to make the request. + are the ones that are needed to make the request return + a successful response. """ def start_requests(self): @@ -51,14 +52,18 @@ def parse(self, response): time_note = response.css("div#widget_45_2122_758 p::text").get() for row_item, script_item in zip(rows, scripts): - content = json.loads(script_item) + try: + content = json.loads(script_item) + except json.JSONDecodeError as e: + self.logger.error(f"Failed to parse JSON: {e}") + continue meeting = Meeting( title="Atlantic County Board of County Commissioners", description="", classification=BOARD, - start=self._parse_start(content), - end=self._parse_end(content), + start=self._parse_start(row_item), + end=None, all_day=False, time_notes=time_note.strip(), location=self._parse_location(content), @@ -72,12 +77,11 @@ def parse(self, response): yield meeting def _parse_start(self, item): - """Parse start datetime as a naive datetime object.""" - return dateparse(item["startDate"]).astimezone(tz=None).replace(tzinfo=None) + item = Selector(text=item) + start_dt = item.css("time::text").get().strip() + start_dt = dateparse(start_dt) - def _parse_end(self, item): - """Parse end datetime as a naive datetime object.""" - return dateparse(item["endDate"]).astimezone(tz=None).replace(tzinfo=None) + return start_dt def _parse_location(self, item): location = item.get("location") diff --git a/tests/test_atconj_County_Commission.py b/tests/test_atconj_County_Commission.py index 46875fc..7d142a2 100644 --- a/tests/test_atconj_County_Commission.py +++ b/tests/test_atconj_County_Commission.py @@ -35,7 +35,7 @@ def test_start(): def test_end(): - assert parsed_items[0]["end"] == datetime(2025, 1, 7, 23, 59) + assert parsed_items[0]["end"] == None def test_time_notes():