String value for order of Scrapy component
See original GitHub issueIf Scrapy component order is defined as a string, it leads to undefined behaviour on Python 2 and to the following errors on Python 3:
File "/usr/local/lib/python3.5/site-packages/scrapy/middleware.py", line 58, in from_crawler
return cls.from_settings(crawler.settings, crawler)
File "/usr/local/lib/python3.5/site-packages/scrapy/middleware.py", line 29, in from_settings
mwlist = cls._get_mwlist_from_settings(settings)
File "/usr/local/lib/python3.5/site-packages/scrapy/core/spidermw.py", line 21, in _get_mwlist_from_settings
return build_component_list(settings.getwithbase('SPIDER_MIDDLEWARES'))
File "/usr/local/lib/python3.5/site-packages/scrapy/utils/conf.py", line 47, in build_component_list
return [k for k, v in sorted(six.iteritems(compdict), key=itemgetter(1))]
builtins.TypeError: unorderable types: str() < int()
My guess that 1) order of a Scrapy component should be stated as of integer type (or None
) and there should be a check somewhere, 2) or the sorting logic should be fixed.
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Requests and Responses — Scrapy 2.7.1 documentation
The dict values can be strings (for single valued headers) or lists (for multi-valued headers). If None is passed as value, the HTTP...
Read more >Order a json by field using scrapy - python - Stack Overflow
seem not to be so simple. I've studied every single component (middlewares, pipelines, exporters, signals, etc...) but no one seems useful for ...
Read more >Scrapy Beginners Series Part 2 - Cleaning & Processing Data
Python Scrapy Playbook - Scrapy Beginner Series Part 2: Cleaning ... The integer values you assign to classes in this setting determine the...
Read more >How to use Scrapy Items? - GeeksforGeeks
It consists of key-value pair, of Field objects used, ... Scrapy provides us, with Selectors, to “select” parts of the webpage, desired.
Read more >An Introduction | Python Scrapy Tutorial - Great Learning
get_value(value,*processors,**kw) – given value is processed by the processors. get_xpath(xpath,*processors,**kw) – xpath will extract list of Unicode strings ...
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
PR created ☝️ Thanks for your comment Viktor 😃
@elacuesta Makes sense to me, that would be nice, thanks. In my case I encountered with a string with an integer inside as order, so it should be covered by the similar changes. Btw there’s no need to strip value before converting to int, but that’s nitpicking 😃