-
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
4 changed files
with
66 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import scrapy | ||
|
||
from kingfisher_scrapy.base_spider import LinksSpider | ||
from kingfisher_scrapy.util import parameters | ||
|
||
|
||
class HondurasPortalBase(LinksSpider): | ||
next_pointer = '/next' | ||
next_page_formatter = staticmethod(parameters('page')) | ||
publishers = ['oncae', 'sefin'] | ||
|
||
download_delay = 0.9 | ||
|
||
@classmethod | ||
def from_crawler(cls, crawler, publisher=None, *args, **kwargs): | ||
spider = super().from_crawler(crawler, publisher=publisher, *args, **kwargs) | ||
if publisher and publisher not in spider.publishers: | ||
raise scrapy.exceptions.CloseSpider('Specified publisher is not recognized') | ||
|
||
return spider | ||
|
||
def start_requests(self): | ||
url = self.url | ||
if self.publisher: | ||
url = url + '&publisher=' + self.publisher | ||
yield scrapy.Request(url, meta={'file_name': 'page-1.json'}) |
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 |
---|---|---|
@@ -1,28 +1,23 @@ | ||
import scrapy | ||
from kingfisher_scrapy.spiders.honduras_portal_base import HondurasPortalBase | ||
|
||
from kingfisher_scrapy.base_spider import LinksSpider | ||
from kingfisher_scrapy.util import parameters | ||
|
||
|
||
class HondurasPortalRecords(LinksSpider): | ||
class HondurasPortalRecords(HondurasPortalBase): | ||
""" | ||
API documentation | ||
http://www.contratacionesabiertas.gob.hn/manual_api/ | ||
Swagger API documentation | ||
http://www.contratacionesabiertas.gob.hn/servicio/ | ||
Spider arguments | ||
publisher | ||
Filter the data by a specific publisher. | ||
``oncae`` for "Oficina Normativa de Contratación y Adquisiciones del Estado" publisher. | ||
``sefin`` for "Secretaria de Finanzas de Honduras" publisher. | ||
sample | ||
Download only the first record package in the dataset. | ||
If ``publisher'' is also provided, a single package is downloaded from that publisher. | ||
""" | ||
name = 'honduras_portal_records' | ||
data_type = 'record_package' | ||
data_pointer = '/recordPackage' | ||
next_pointer = '/next' | ||
next_page_formatter = staticmethod(parameters('page')) | ||
skip_pluck = 'Already covered (see code for details)' # honduras_portal_releases | ||
|
||
download_delay = 0.9 | ||
|
||
def start_requests(self): | ||
url = 'http://www.contratacionesabiertas.gob.hn/api/v1/record/?format=json' | ||
yield scrapy.Request(url, meta={'file_name': 'page-1.json'}) | ||
url = 'http://www.contratacionesabiertas.gob.hn/api/v1/record/?format=json' |
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 |
---|---|---|
@@ -1,27 +1,22 @@ | ||
import scrapy | ||
from kingfisher_scrapy.spiders.honduras_portal_base import HondurasPortalBase | ||
|
||
from kingfisher_scrapy.base_spider import LinksSpider | ||
from kingfisher_scrapy.util import parameters | ||
|
||
|
||
class HondurasPortalReleases(LinksSpider): | ||
class HondurasPortalReleases(HondurasPortalBase): | ||
""" | ||
API documentation | ||
http://www.contratacionesabiertas.gob.hn/manual_api/ | ||
Swagger API documentation | ||
http://www.contratacionesabiertas.gob.hn/servicio/ | ||
Spider arguments | ||
publisher | ||
Filter the data by a specific publisher. | ||
``oncae`` for "Oficina Normativa de Contratación y Adquisiciones del Estado" publisher. | ||
``sefin`` for "Secretaria de Finanzas de Honduras" publisher. | ||
sample | ||
Download only the first release package in the dataset. | ||
If ``publisher'' is also provided, a single package is downloaded from that publisher. | ||
""" | ||
name = 'honduras_portal_releases' | ||
data_type = 'release_package' | ||
data_pointer = '/releasePackage' | ||
next_pointer = '/next' | ||
next_page_formatter = staticmethod(parameters('page')) | ||
|
||
download_delay = 0.9 | ||
|
||
def start_requests(self): | ||
url = 'http://www.contratacionesabiertas.gob.hn/api/v1/release/?format=json' | ||
yield scrapy.Request(url, meta={'file_name': 'page-1.json'}) | ||
url = 'http://www.contratacionesabiertas.gob.hn/api/v1/release/?format=json' |