-
Notifications
You must be signed in to change notification settings - Fork 12
/
ecuador_emergency.py
29 lines (23 loc) · 964 Bytes
/
ecuador_emergency.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import scrapy
from kingfisher_scrapy.base_spider import SimpleSpider
from kingfisher_scrapy.util import components, handle_http_error
class EcuadorEmergency(SimpleSpider):
"""
Bulk download documentation
https://portal.compraspublicas.gob.ec/sercop/data-estandar-ocds/
Spider arguments
sample
Downloads one release package from the first link in the downloads page.
"""
name = 'ecuador_emergency'
data_type = 'release_package'
def start_requests(self):
url = 'https://datosabiertos.compraspublicas.gob.ec/OCDS/'
yield scrapy.Request(url, meta={'file_name': 'list.html'}, callback=self.parse_list)
@handle_http_error
def parse_list(self, response):
html_urls = response.xpath('//a/@href').getall()
for html_url in html_urls:
yield self.build_request(response.request.url + html_url, formatter=components(-1))
if self.sample:
break