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
FEED_URI_PARAMS: custom params throws KeyError #4962
Comments
Indeed: scrapy/scrapy/extensions/feedexport.py Lines 487 to 488 in 85604e1
For your specific use case, though, I think you can just use scrapy/scrapy/extensions/feedexport.py Lines 480 to 481 in 85604e1
|
|
Yes, %(name)s was my workaround solution. Thanks for your comment, Gallaecio. |
|
Hi @jas0nkim @Gallaecio, I'm new here. Can I take this issue? :) |
|
@inspurwusixuan Please go ahead! |
|
Is this issue still available? |
|
Not really, there is already a pull request, #4966, which only needs 1 more maintainer review before being merged. |
|
@Gallaecio Ok. Do you know if there is currently an issue that is available that I might be able to contribute to as a first time open source developer? |
|
We run out of good first issues quite quickly, and I’m not sure we have anything like that open at the moment |
|
Ok. Thank you |
Description
With Scrapy version 2.4.1, any custom feed uri params (FEED_URI_PARAMS) throws KeyError.
Steps to Reproduce
on myproject/settings.py
FEED_URI_PARAMS = 'myproject.utils.uri_params'
on myproject/utils.py
def uri_params(params, spider):
return {**params, 'spider_name': spider.name}
scrapy crawl <spider_name> -o "%(spider_name)s.jl"
Expected behavior: Should export the items to a jsonline file having the spider name.
Actual behavior:
ERROR: Error caught on signal handler: <bound method FeedExporter.open_spider of <scrapy.extensions.feedexport.FeedExporter object at 0x7fc68cb20bb0>>
Traceback (most recent call last):
File "/PROJECT_ROOT/.venv/lib/python3.8/site-packages/scrapy/utils/defer.py", line 157, in maybeDeferred_coro
result = f(*args, **kw)
File "/PROJECT_ROOT/.venv/lib/python3.8/site-packages/pydispatch/robustapply.py", line 55, in robustApply
return receiver(*arguments, **named)
File "/PROJECT_ROOT/.venv/lib/python3.8/site-packages/scrapy/extensions/feedexport.py", line 294, in open_spider
uri=uri % uri_params,
KeyError: 'spider_name'
Reproduces how often: Everytime
Versions
Scrapy : 2.4.1
lxml : 4.6.1.0
libxml2 : 2.9.10
cssselect : 1.1.0
parsel : 1.6.0
w3lib : 1.22.0
Twisted : 20.3.0
Python : 3.8.5 (default, Jul 28 2020, 12:59:40) - [GCC 9.3.0]
pyOpenSSL : 19.1.0 (OpenSSL 1.1.1h 22 Sep 2020)
cryptography : 3.2.1
Platform : Linux-4.19.104-microsoft-standard-x86_64-with-glibc2.29
Additional context
on line 480 in /scrapy/extensions/feedexport.py,
returns params should be changed to return uripar_function(params, spider)
The text was updated successfully, but these errors were encountered: