-
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
2 changed files
with
48 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,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)) |
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,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'}) |