Skip to content

Commit

Permalink
united_kingdom_contracts_finder: update to download record packages
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravf95 committed Apr 5, 2022
1 parent 37fff6b commit fdb1d6c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kingfisher_scrapy/spiders/united_kingdom_contracts_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ class UnitedKingdomContractsFinder(IndexSpider):

# BaseSpider
ocds_version = '1.0' # uses deprecated fields
root_path = 'results.item'

# SimpleSpider
data_type = 'release_package'
data_type = 'record_package'

# IndexSpider
total_pages_pointer = '/maxPage'
Expand All @@ -30,7 +29,11 @@ def start_requests(self):

def parse(self, response, **kwargs):
if self.is_http_success(response):
yield from super().parse(response)
for result in response.json()['results']:
for release in result['releases']:
ocid = release["ocid"]
url = f'https://www.contractsfinder.service.gov.uk/Published/OCDS/Record/{ocid}'
yield scrapy.Request(url, meta={'file_name': f'{ocid}.json'}, callback=super().parse)
else:
request = response.request.copy()
wait_time = int(response.headers.get('Retry-After', 1))
Expand Down

0 comments on commit fdb1d6c

Please sign in to comment.