-
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
3 changed files
with
51 additions
and
0 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,23 @@ | ||
import json | ||
|
||
import scrapy | ||
|
||
from kingfisher_scrapy.base_spider import SimpleSpider | ||
from kingfisher_scrapy.util import components, handle_http_error | ||
|
||
|
||
class NigeriaBudeshiBase(SimpleSpider): | ||
def start_requests(self): | ||
yield scrapy.Request( | ||
'https://budeshi.ng/api/project_list', | ||
meta={'file_name': 'project_list.json'}, | ||
callback=self.parse_list | ||
) | ||
|
||
@handle_http_error | ||
def parse_list(self, response): | ||
project_list = json.loads(response.text) | ||
for project in project_list: | ||
yield self.build_request(self.url.format(project['id']), formatter=components(-2)) | ||
if self.sample: | ||
return |
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,14 @@ | ||
from kingfisher_scrapy.spiders.nigeria_budeshi_base import NigeriaBudeshiBase | ||
|
||
|
||
class NigeriaBudeshiRecords(NigeriaBudeshiBase): | ||
""" | ||
API documentation | ||
https://budeshi.ng/Api | ||
Spider arguments | ||
sample | ||
Download only the record package with project id = 1. | ||
""" | ||
name = 'nigeria_budeshi_records' | ||
data_type = 'record_package' | ||
url = 'https://budeshi.ng/api/record/{}' |
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,14 @@ | ||
from kingfisher_scrapy.spiders.nigeria_budeshi_base import NigeriaBudeshiBase | ||
|
||
|
||
class NigeriaBudeshiReleases(NigeriaBudeshiBase): | ||
""" | ||
API documentation | ||
https://budeshi.ng/Api | ||
Spider arguments | ||
sample | ||
Download only the release package with project id = 1. | ||
""" | ||
name = 'nigeria_budeshi_releases' | ||
data_type = 'release_package' | ||
url = 'https://budeshi.ng/api/releases/{}' |