Skip to content

Commit

Permalink
made improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
msrezaie committed Dec 16, 2024
1 parent c36258f commit 4360388
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
22 changes: 13 additions & 9 deletions city_scrapers/spiders/atconj_County_Commission.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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),
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_atconj_County_Commission.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit 4360388

Please sign in to comment.