Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slovenia: new spider #675

Merged
merged 3 commits into from
Mar 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/spiders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,16 @@ Scotland

scrapy crawl scotland_public_contracts

Slovenia
--------

.. autoclass:: kingfisher_scrapy.spiders.slovenia.Slovenia
:no-members:

.. code-block:: bash

scrapy crawl slovenia

Spain
-----

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

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


class Slovenia(SimpleSpider):
"""
Domain
Ministry of Public Administration Slovenia
"""
name = 'slovenia'

# SimpleSpider
data_type = 'release_package'

url = 'http://tbfy.ijs.si/public/ocds/mju/'

def start_requests(self):
yield scrapy.Request(self.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 url in html_urls:
if 'ocds' and 'json' in url:
yield self.build_request(f'{self.url}{url}', formatter=components(-1))