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

TypeError: string indices must be integers, not str #62

Open
lnsyyj opened this issue Aug 14, 2017 · 7 comments
Open

TypeError: string indices must be integers, not str #62

lnsyyj opened this issue Aug 14, 2017 · 7 comments

Comments

@lnsyyj
Copy link

lnsyyj commented Aug 14, 2017

2017-08-15 00:20:29 [scrapy] ERROR: Error downloading <GET http://weibo.cn/5818747476/profile?filter=1&page=1>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/scrapy/utils/defer.py", line 45, in mustbe_deferred
result = f(*args, **kw)
File "/usr/local/lib/python2.7/dist-packages/scrapy/core/downloader/middleware.py", line 32, in process_request
response = method(request=request, spider=spider)
File "/usr/local/lib/python2.7/dist-packages/scrapy/downloadermiddlewares/cookies.py", line 32, in process_request
cookies = self._get_request_cookies(jar, request)
File "/usr/local/lib/python2.7/dist-packages/scrapy/downloadermiddlewares/cookies.py", line 87, in _get_request_cookies
cookies = [self._format_cookie(x) for x in cookie_list]
File "/usr/local/lib/python2.7/dist-packages/scrapy/downloadermiddlewares/cookies.py", line 71, in _format_cookie
cookie_str = '%s=%s' % (cookie['name'], cookie['value'])
TypeError: string indices must be integers, not str
2017-08-15 00:20:29 [scrapy] INFO: Closing spider (finished)
2017-08-15 00:20:29 [scrapy] INFO: Dumping Scrapy stats:

@leitang
Copy link

leitang commented Aug 18, 2017

运行Spider1的时候我也遇到了同样的问题

@pythonmanGo
Copy link

同样的问题,无法继续!

@tanmq
Copy link

tanmq commented Oct 27, 2017

同样的问题,为毛呢?

@tanmq
Copy link

tanmq commented Oct 27, 2017

找到原因了,修改cookies.py文件的71行:

return json.dumps(cookie)

return cookie
不用转化json字符串,直接returncookie就好了

@mengjinglei
Copy link

@tanmq 可以提个pr修复一下

@cap-ljf
Copy link

cap-ljf commented Mar 9, 2018

@tanmq 感谢

1 similar comment
@kilakila-heart
Copy link

@tanmq 感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants