-
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.
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
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,34 @@ | ||
from kingfisher_scrapy.base_spider import SimpleSpider | ||
from kingfisher_scrapy.util import components | ||
|
||
|
||
class NicaraguaSolidWaste(SimpleSpider): | ||
""" | ||
Spider arguments | ||
sample | ||
Download only data released on 2013-01-23 | ||
from_date | ||
Download only data from this date onward (YYYY-MM-DD format). | ||
If ``until_date`` is provided, defaults to '2000-01-01'. | ||
until_date | ||
Download only data until this date (YYYY-MM-DD format). | ||
If ``from_date`` is provided, defaults to today. | ||
""" | ||
name = 'nicaragua_solid_waste' | ||
data_type = 'release_package' | ||
default_from_date = '2000-01-01' | ||
date_required = True | ||
url = 'http://www.gekoware.com/swmp/api/ocds/{}/{}' | ||
|
||
def start_requests(self): | ||
url = self.url | ||
if self.sample: | ||
# date parameter setting to get one release from 2013 | ||
url = url.format('20130123', '20130123') | ||
else: | ||
if self.from_date and self.until_date: | ||
# date parameter obtained | ||
url = url.format(self.from_date.strftime("%Y%m%d"), self.until_date.strftime("%Y%m%d")) | ||
|
||
# url looks like http://www.gekoware.com/swmp/api/ocds/20190101/20201005 | ||
yield self.build_request(url, formatter=components(-2)) |