-
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.
feat: add albania_public_procurement_commission_historical and base c…
…lass
- Loading branch information
Showing
4 changed files
with
68 additions
and
26 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
29 changes: 29 additions & 0 deletions
29
kingfisher_scrapy/spiders/albania_public_procurement_commission_base.py
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,29 @@ | ||
import json | ||
|
||
import scrapy | ||
|
||
from kingfisher_scrapy import util | ||
from kingfisher_scrapy.base_spiders import SimpleSpider | ||
|
||
|
||
class AlbaniaPublicProcurementCommissionBase(SimpleSpider): | ||
# BaseSpider | ||
date_format = 'year' | ||
date_required = True | ||
root_path = 'result' | ||
|
||
# SimpleSpider | ||
data_type = 'release_package' | ||
|
||
def start_requests(self): | ||
for year in util.date_range_by_year(self.from_date.year, self.until_date.year): | ||
payload = { | ||
"extraConditions": [ | ||
[self.date_param, ">=", f"1/1/{year}"], | ||
[self.date_param, "<=", f"1/1/{year + 1}"], | ||
] | ||
} | ||
yield scrapy.Request( | ||
self.base_url, meta={'file_name': f'{year}.json'}, method='POST', body=json.dumps(payload), | ||
headers={'Accept': 'application/json', 'Content-Type': 'application/json'} | ||
) |
27 changes: 27 additions & 0 deletions
27
kingfisher_scrapy/spiders/albania_public_procurement_commission_historical.py
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,27 @@ | ||
from kingfisher_scrapy.spiders.albania_public_procurement_commission_base import AlbaniaPublicProcurementCommissionBase | ||
|
||
|
||
class AlbaniaPublicProcurementCommissionHistorical(AlbaniaPublicProcurementCommissionBase): | ||
""" | ||
Domain | ||
Komisioni i Prokurimit Publik (KPP) (Public Procurement Commission) | ||
Spider arguments | ||
from_date | ||
Download only data from this year onward (YYYY format). Defaults to '2010'. | ||
until_date | ||
Download only data until this year (YYYY format). Defaults to '2020'. | ||
Bulk download documentation | ||
https://kpp.al/en/HistorikVendimesh?objektProkurimi=&viti=&vitiId=&muaji=&muajiId= | ||
""" | ||
|
||
name = 'albania_public_procurement_commission_historical' | ||
|
||
# BaseSpider | ||
default_from_date = '2010' | ||
default_until_date = '2020' | ||
skip_pluck = 'Already covered (see code for details)' # albania_public_procurement_commission | ||
|
||
# AlbaniaPublicProcurementCommissionBase | ||
base_url = 'https://kpp.al/api/public/Decision/getHistoricBulkJsonByYear' | ||
date_param = 'prot_date' |