-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #971 from open-contracting/957-anambra
nigeria: Add Bon Maximus base, update nigeria_anambra_state
- Loading branch information
Showing
5 changed files
with
45 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from kingfisher_scrapy.spiders.nigeria_bon_maximus_base import NigeriaBonMaximusBase | ||
|
||
|
||
class NigeriaAnambraState(NigeriaBonMaximusBase): | ||
""" | ||
Domain | ||
Anambra State | ||
API documentation | ||
https://eprocure.bpp.an.gov.ng/awarded_contracts.php | ||
""" | ||
name = 'nigeria_anambra_state' | ||
|
||
# SimpleSpider | ||
data_type = 'release_package' | ||
|
||
# NigeriaBonMaximusBase | ||
url_prefix = 'https://eprocure.bpp.an.gov.ng/' |
30 changes: 0 additions & 30 deletions
30
kingfisher_scrapy/spiders/nigeria_anambra_state_records.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import scrapy | ||
|
||
from kingfisher_scrapy.base_spiders import SimpleSpider | ||
from kingfisher_scrapy.util import components, get_parameter_value, handle_http_error | ||
|
||
|
||
class NigeriaBonMaximusBase(SimpleSpider): | ||
# SimpleSpider | ||
data_type = 'release_package' | ||
|
||
# url_prefix must be provided by subclasses. | ||
|
||
def start_requests(self): | ||
url = f'{self.url_prefix}awarded_contracts.php' | ||
yield scrapy.Request(url, meta={'file_name': 'all.html'}, callback=self.parse_list) | ||
|
||
@handle_http_error | ||
def parse_list(self, response): | ||
for url in response.xpath('//table[@id="contractTable"]/tbody/tr/td[2]/a/@href').getall(): | ||
# The URLs look like | ||
# https://url_prefix/existing_award_details.php?id=ocds-xwwr9a-000103-OS/HLT/02 | ||
ocid = get_parameter_value(url, 'id').replace('/', '_') | ||
yield self.build_request(f'{self.url_prefix}media/{ocid}.json', formatter=components(-1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters