diff --git a/kingfisher_scrapy/spiders/nepal_dhangadhi.py b/kingfisher_scrapy/spiders/nepal_dhangadhi.py index 6cc22c71e..0e1a6490b 100644 --- a/kingfisher_scrapy/spiders/nepal_dhangadhi.py +++ b/kingfisher_scrapy/spiders/nepal_dhangadhi.py @@ -28,4 +28,14 @@ def parse_list(self, response): pattern = 'https://admin.ims.susasan.org/ocds/json/dhangadhi-{}.json' data = response.json() for item in data['data']['fiscal_years']: - yield self.build_request(pattern.format(item['name']), formatter=components(-1)) + # A URL might redirect to https://admin.ims.susasan.org/login + yield self.build_request(pattern.format(item['name']), formatter=components(-1), + meta={'dont_redirect': True}) + + def parse(self, response): + # if we got a redirect response we try it again to download that file + if response.status == 302: + yield self.build_request(response.request.url, formatter=components(-1), + dont_filter=True) + else: + yield from super().parse(response)