Skip to content

Commit

Permalink
Merge pull request #1051 from City-Bureau/chore/fix-cron-task
Browse files Browse the repository at this point in the history
[c] Fix cron tasks
  • Loading branch information
haileyhoyat committed Sep 28, 2023
2 parents ee5a6b9 + 020d936 commit c43043d
Show file tree
Hide file tree
Showing 9 changed files with 4,241 additions and 6,700 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/archive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@ jobs:
sudo openvpn --config /etc/openvpn/ovpn.conf --daemon
sleep 120
- name: Set up Python 3.7
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.7
python-version: 3.9

- name: Install Pipenv
uses: dschep/install-pipenv-action@v1

- name: Install dependencies
run: pipenv sync
env:
PIPENV_DEFAULT_PYTHON_VERSION: 3.7
PIPENV_DEFAULT_PYTHON_VERSION: 3.9

- name: Run scrapers
run: |
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
- name: Check imports with isort
run: pipenv run isort . --check-only

- name: Check style with black
run: pipenv run black . --check

- name: Lint with flake8
run: pipenv run flake8 .

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ jobs:
sudo openvpn --config /etc/openvpn/ovpn.conf --daemon
sleep 120
- name: Set up Python 3.7
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.7
python-version: 3.9

- name: Install Pipenv
uses: dschep/install-pipenv-action@v1

- name: Install dependencies
run: pipenv sync
env:
PIPENV_DEFAULT_PYTHON_VERSION: 3.7
PIPENV_DEFAULT_PYTHON_VERSION: 3.9

- name: Run scrapers
run: |
Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ python-dateutil = "*"
pytz = "*"
requests = "*"
scrapy = "*"
scrapy-sentry = "*"
scrapy-sentry = {ref = "v1", git = "https://github.com/City-Bureau/scrapy-sentry.git"}
scrapy-wayback-middleware = "*"
city-scrapers-core = {ref = "main", git = "https://github.com/City-Bureau/city-scrapers-core.git", extras = ["azure"]}
pypiwin32 = {version = "*",sys_platform = "== 'win32'"}
Expand Down
855 changes: 476 additions & 379 deletions Pipfile.lock

Large diffs are not rendered by default.

10 changes: 1 addition & 9 deletions city_scrapers/spiders/chi_citycouncil.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import requests
from city_scrapers_core.constants import NOT_CLASSIFIED
from city_scrapers_core.items import Meeting
from city_scrapers_core.spiders import CityScrapersSpider
Expand All @@ -9,19 +8,12 @@ class ChiCitycouncilSpider(CityScrapersSpider):
name = "chi_citycouncil"
agency = "Chicago City Council"
timezone = "America/Chicago"
start_urls = ["https://chicityclerkelms.chicago.gov/Meetings/"]
start_urls = ["https://api.chicityclerkelms.chicago.gov/meeting"]

def parse(self, response):

# The API endpoint
url = "https://api.chicityclerkelms.chicago.gov/meeting" # noqa

# A GET request to the API
response = requests.get(url)
response_json = response.json()

for item in response_json["data"]:

meeting = Meeting(
title=self._parse_title(item),
description=self._parse_description(item),
Expand Down
6 changes: 3 additions & 3 deletions city_scrapers/spiders/chi_midway_noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def parse(self, response):
yield from meeting_list

def _parse_title(self, item):
if type(item) == Selector:
if isinstance(item, Selector):
item = item.get()
text = self._clean_bad_chars(item)
desc = ""
Expand All @@ -113,7 +113,7 @@ def _parse_start(self, item):

def _parse_date(self, item):
"""Parse the meeting date."""
if type(item) == Selector:
if isinstance(item, Selector):
# Scheduled meetings have only text; past meetings have <td> tags.
if "<td>" in item.get():
item = item.xpath(".//td/text()").get()
Expand All @@ -135,7 +135,7 @@ def _parse_date(self, item):
def _parse_links(self, item, response):
"""Parse or generate links."""
documents = []
if type(item) == Selector:
if isinstance(item, Selector):
relative_urls = item.xpath(".//a/@href").extract()
for relative_url in relative_urls:
documents.append(self._build_link_dict(response.urljoin(relative_url)))
Expand Down
Loading

0 comments on commit c43043d

Please sign in to comment.