请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

AttributeError: 'Chrome' object has no attribute 'keep_user_data_dir'

Traceback (most recent call last):
File “/home/wyx/anaconda3/envs/tf2/lib/python3.8/site-packages/scrapy/core/engine.py”, line 129, in _next_request
request = next(slot.start_requests)
File “/home/wyx/python/project/news/news/spiders/zhihu.py”, line 17, in start_requests
l = Login(USER, PASSWORD, 6)
File “/home/wyx/python/project/news/news/utils/zhihu_log_sel.py”, line 222, in init
self.browser = uc.Chrome()
File “/home/wyx/anaconda3/envs/tf2/lib/python3.8/site-packages/undetected_chromedriver/v2.py”, line 152, in init
patcher.auto()
File “/home/wyx/anaconda3/envs/tf2/lib/python3.8/site-packages/undetected_chromedriver/patcher.py”, line 104, in auto
self.unzip_package(self.fetch_package())
File “/home/wyx/anaconda3/envs/tf2/lib/python3.8/site-packages/undetected_chromedriver/patcher.py”, line 141, in fetch_package
return urlretrieve(u)[0]
File “/home/wyx/anaconda3/envs/tf2/lib/python3.8/urllib/request.py”, line 286, in urlretrieve
raise ContentTooShortError(
urllib.error.ContentTooShortError: <urlopen error retrieval incomplete: got only 5865472 out of 5980285 bytes>
Exception ignored in: <function Chrome.del at 0x7f676c089f70>
Traceback (most recent call last):
File “/home/wyx/anaconda3/envs/tf2/lib/python3.8/site-packages/undetected_chromedriver/v2.py”, line 590, in del
self.quit()
File “/home/wyx/anaconda3/envs/tf2/lib/python3.8/site-packages/undetected_chromedriver/v2.py”, line 573, in quit
if not self.keep_user_data_dir or self.keep_user_data_dir is False:
AttributeError: ‘Chrome’ object has no attribute 'keep_user_data_dir’
Exception ignored in: <function Login.del at 0x7f676c090820>
Traceback (most recent call last):
File “/home/wyx/python/project/news/news/utils/zhihu_log_sel.py”, line 332, in del
self.browser.close()
AttributeError: ‘Login’ object has no attribute ‘browser’

我是3.8的环境

正在回答 回答被采纳积分+3

插入代码

1回答

bobby 2021-09-07 10:07:50

https://img1.sycdn.imooc.com//szimg/6136c9340919193509940185.jpg 这里异常栈非常清楚的说明了是哪一行代码的问题以及原因。也就是没有这个browser,注释掉真一行再试试

0 回复 有任何疑惑可以回复我~
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号