raise CloseSpider("Error Message") is not saving error message
See original GitHub issueWhen I run the code raise CloseSpider("Error Message")
in the Spider parse function, the reason gets saved in the finish_reason stats string.
When it is run in the start_requests function, the spider properly closes but the finish_reason does not have the message it in. The finish_reason value is “finished” instead of “Error Message” as set in the CloseSpider exception.
Is this intentional or a bug? thanks!
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:12 (7 by maintainers)
Top Results From Across the Web
handle scrapy exception CloseSpider - python - Stack Overflow
2019-08-10 14:55:56 [scrapy.utils.signal] ERROR: Error caught on signal ... in _open raise CloseSpider(reason='no_file') scrapy.exceptions.
Read more >Exceptions — Scrapy 2.7.1 documentation
This exception can be raised from a spider callback to request the spider to be closed/stopped. Supported arguments: Parameters. reason (str) – ...
Read more >Python scrapy.exceptions.DropItem() Examples
REQUIRED_RE.search(error.message) if required_match: ... if not spider.item_filter(item): raise DropItem('Custom item filter did not allow ... Not saving.
Read more >[Example code]-Scrapy spider not terminating with use of ...
From reading the Scrapy docs I identified I need to use the CloseSpider extension. I have followed the guide on how to enable...
Read more >for notable python repositories - issuebase
raise CloseSpider ("Error Message") is not saving error message. 10/15/2018. enhancementgood first issue · [bug] pillow will always recode images in ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If someone needs a workaround to raise a
CloseSpider
with a specific message in thestart_requests
method before the fix is released, we did something like this:Of course, you can change the try/except by a if/else or whatever you want and the “url” by any other URL. The “magic” here occurs when calling the callback, as the reason of the
CloseSpider
will be respected.@Gallaecio I beg to differ, but I don’t think this is a bug, since the docs do say the exception “can be raised from a spider callback”. Any change to allow raising the exception from other components should be considered an enhancement IMHO.