-
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 branch 'master' into 337-index-spider
# Conflicts: # kingfisher_scrapy/base_spider.py # kingfisher_scrapy/spiders/honduras_portal_records.py # kingfisher_scrapy/spiders/honduras_portal_releases.py
- Loading branch information
Showing
17 changed files
with
335 additions
and
179 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
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 @@ | ||
import scrapy | ||
|
||
from kingfisher_scrapy.base_spider import IndexSpider | ||
from kingfisher_scrapy.util import parameters | ||
|
||
|
||
class HondurasPortalBase(IndexSpider): | ||
next_pointer = '/next' | ||
formatter = staticmethod(parameters('page')) | ||
total_pages_pointer = '/pages' | ||
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'}, callback=self.parse_list) |
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 IndexSpider | ||
from kingfisher_scrapy.util import parameters | ||
|
||
|
||
class HondurasPortalRecords(IndexSpider): | ||
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' | ||
total_pages_pointer = '/pages' | ||
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'}, callback=self.parse_list) | ||
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 IndexSpider | ||
from kingfisher_scrapy.util import parameters | ||
|
||
|
||
class HondurasPortalReleases(IndexSpider): | ||
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' | ||
total_pages_pointer = '/pages' | ||
formatter = staticmethod(parameters('page')) | ||
|
||
download_delay = 0.9 | ||
|
||
def start_requests(self): | ||
yield scrapy.Request('http://www.contratacionesabiertas.gob.hn/api/v1/release/?format=json', | ||
meta={'file_name': 'page-1.json'}, callback=self.parse_list) | ||
url = 'http://www.contratacionesabiertas.gob.hn/api/v1/release/?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
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
Oops, something went wrong.