python调用selenium打开chrome浏览器失败
PHP中文网
PHP中文网 2017-04-18 10:01:48
[Python讨论组]

如题,代码如下:

import socket
socket.setdefaulttimeout(20)

chromepath = os.path.abspath(r"C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe")
driver = webdriver.Chrome(chromepath)
driver.get("https://www.baidu.com")
print driver.title
driver.close()

报错如下:

Traceback (most recent call last):
  File "C:/Users/CurryXu/Desktop/selenium+phantomjs/experiment/joy.py", line 9, in <module>
    driver.get("https://www.baidu.com")
  File "C:\Python27\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 248, in get
    self.execute(Command.GET, {'url': url})
  File "C:\Python27\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\webdriver.py", line 234, in execute
    response = self.command_executor.execute(driver_command, params)
  File "C:\Python27\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\remote_connection.py", line 407, in execute
    return self._request(command_info[0], url, body=data)
  File "C:\Python27\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\remote\remote_connection.py", line 439, in _request
    resp = self._conn.getresponse()
  File "C:\Python27\lib\httplib.py", line 1136, in getresponse
    response.begin()
  File "C:\Python27\lib\httplib.py", line 453, in begin
    version, status, reason = self._read_status()
  File "C:\Python27\lib\httplib.py", line 409, in _read_status
    line = self.fp.readline(_MAXLINE + 1)
  File "C:\Python27\lib\socket.py", line 480, in readline
    data = self._sock.recv(self._rbufsize)
socket.error: [Errno 10054] 

打开的chrome浏览器显示如下:

请问这是什么原因导致打开浏览器无反应呢

PHP中文网
PHP中文网

认证0级讲师

全部回复(1)
怪我咯

更新下驱动,地址
见这个回答

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号