Skip to content

Commit

Permalink
Add kaduna state spiders
Browse files Browse the repository at this point in the history
  • Loading branch information
cecicasco committed Jun 21, 2021
1 parent c4f1c38 commit fac9ab4
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/spiders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,23 @@ Italy
scrapy crawl italy
Kaduna
------

.. autoclass:: kingfisher_scrapy.spiders.kaduna_state_records.KadunaStateBudeshiRecords
:no-members:

.. code-block:: bash
scrapy crawl kaduna_state_records
.. autoclass:: kingfisher_scrapy.spiders.kaduna_state_releases.KadunaStateBudeshiReleases
:no-members:

.. code-block:: bash
scrapy crawl kaduna_state_releases
Kenya
-----

Expand Down
30 changes: 30 additions & 0 deletions kingfisher_scrapy/spiders/kaduna_state_records.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import scrapy

from kingfisher_scrapy.base_spider import SimpleSpider
from kingfisher_scrapy.util import components, handle_http_error


class KadunaStateBudeshiRecords(SimpleSpider):
"""
Domain
Kaduna State
Bulk download documentation
https://www.budeshi.ng/kadppa/api
"""
name = 'kaduna_state_records'

# SimpleSpider
data_type = 'record_package'
base_url = 'https://www.budeshi.ng/kadppa/api/'

def start_requests(self):
url = f'{self.base_url}project_list'
yield scrapy.Request(url, meta={'file_name': 'list.json'}, callback=self.parse_list)

@handle_http_error
def parse_list(self, response):
data = response.json()
for item in data:
id = item['id']
url = f'{self.base_url}record/{id}'
yield self.build_request(url, formatter=components(-2))
32 changes: 32 additions & 0 deletions kingfisher_scrapy/spiders/kaduna_state_releases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import scrapy

from kingfisher_scrapy.base_spider import SimpleSpider
from kingfisher_scrapy.util import components, handle_http_error


class KadunaStateBudeshiReleases(SimpleSpider):
"""
Domain
Kaduna State
Bulk download documentation
https://www.budeshi.ng/kadppa/api
"""
name = 'kaduna_state_releases'

# SimpleSpider
data_type = 'release_package'
base_url = 'https://www.budeshi.ng/kadppa/api/'

def start_requests(self):
url = f'{self.base_url}project_list'
yield scrapy.Request(url, meta={'file_name': 'list.json'}, callback=self.parse_list)

@handle_http_error
def parse_list(self, response):
types = ['planning', 'tender', 'award', 'contract']
data = response.json()
for item in data:
id = item['id']
for type in types:
url = f'{self.base_url}record/{id}/{type}'
yield self.build_request(url, formatter=components(-2))

0 comments on commit fac9ab4

Please sign in to comment.