|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 Bruning 于 2020-8-13 01:25 编辑
Traceback (most recent call last):
File "D:/py存储库/爬虫/doubanTop250.py", line 62, in <module>
main()
File "D:/py存储库/爬虫/doubanTop250.py", line 49, in main
res = open_url(host)
File "D:/py存储库/爬虫/doubanTop250.py", line 9, in open_url
res = requests.get(url,headers = headers)
File "C:\Users\37984\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\requests\api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "C:\Users\37984\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Users\37984\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\requests\sessions.py", line 516, in request
prep = self.prepare_request(req)
File "C:\Users\37984\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\requests\sessions.py", line 449, in prepare_request
p.prepare(
File "C:\Users\37984\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\requests\models.py", line 315, in prepare
self.prepare_headers(headers)
File "C:\Users\37984\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\requests\models.py", line 447, in prepare_headers
for header in headers.items():
AttributeError: 'str' object has no attribute 'items'
这什么原因啊 求99 跟着书做下来的代码 |
|