Skip to content

Commit

Permalink
Merge c15e3db into 188b408
Browse files Browse the repository at this point in the history
  • Loading branch information
aguilerapy committed Nov 25, 2020
2 parents 188b408 + c15e3db commit b14499c
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
31 changes: 31 additions & 0 deletions kingfisher_scrapy/spiders/pakistan_ppra_records.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import json

import scrapy

from kingfisher_scrapy.spiders.honduras_portal_base import HondurasPortalBase
from kingfisher_scrapy.util import handle_http_error, components


class HondurasPortalRecords(HondurasPortalBase):
"""
Domain
Pakistan Public Procurement Regulatory Authority (PPRA)
API documentation
https://www.ppra.org.pk/api/
"""
name = 'pakistan_ppra_records'
data_type = 'record_package'

def start_requests(self):
yield scrapy.Request(
'https://www.ppra.org.pk/api/index.php/api/records',
meta={'file_name': 'list.html'},
callback=self.parse_list
)

@handle_http_error
def parse_list(self, response):
# remove the last item in the list to fix the str JSON format
urls = json.loads(response.xpath('//body//text()').getall()[6].replace(",\r\n\r\nhttps://www.ppra.org.pk", ""))
for url in urls:
yield self.build_request(url, formatter=components(-2))
17 changes: 17 additions & 0 deletions kingfisher_scrapy/spiders/pakistan_ppra_releases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import scrapy

from kingfisher_scrapy.spiders.honduras_portal_base import HondurasPortalBase


class HondurasPortalReleases(HondurasPortalBase):
"""
Domain
Pakistan Public Procurement Regulatory Authority (PPRA)
API documentation
https://www.ppra.org.pk/api/
"""
name = 'pakistan_ppra_releases'
data_type = 'release_package'

def start_requests(self):
yield scrapy.Request('https://www.ppra.org.pk/api/index.php/api/release', meta={'file_name': 'releases.json'})

0 comments on commit b14499c

Please sign in to comment.