Skip to content

Commit

Permalink
Merge pull request #1064 from open-contracting/1053-fix-zambia
Browse files Browse the repository at this point in the history
fix(EuropeanDynamicsBase): check for valid JSON files
  • Loading branch information
yolile committed Apr 5, 2024
2 parents 0aaa82a + cfaec28 commit 61188e0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion kingfisher_scrapy/spiders/european_dynamics_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
from json import JSONDecodeError
from urllib.parse import urlsplit

import scrapy
Expand Down Expand Up @@ -44,7 +45,12 @@ def start_requests(self):

@handle_http_error
def parse_list(self, response):
for number, url in enumerate(reversed(response.json()['packagesPerMonth'])):
try:
data = response.json()
# The response can be an HTML document with an error message like "temporary unavailable due to maintenance".
except JSONDecodeError:
return self.build_file_error_from_response(response, errors=response.text)
for number, url in enumerate(reversed(data['packagesPerMonth'])):
path = urlsplit(url).path
if self.from_date and self.until_date:
# URL looks like https://www.zppa.org.zm/ocds/services/recordpackage/getrecordpackage/2016/7
Expand Down

0 comments on commit 61188e0

Please sign in to comment.