Uninote
Uninote
用户根目录
emoji test🧚
欢迎你
爱神的飞刀
都市风光
🧚🧚
🧚🧚2
🧚🧚3
__import__
ELK集群部署
JS面向对象函数的四种调用模式
Java入门学习路线目录索引(持续更新中)
c
个人文库
掘金
ElasticSearch + Logstash进行数据库同步
ElasticSearch两个节点的情况下,shard是如何分配的
ElasticSearch安装教程
ElasticSearch设置用户名密码访问
ElasticSearch适用场景,功能以及特点介绍
Kali Linux安装教程
Linux设置虚拟内存教学和实战
Xdebug文档(一)基本特性
docker
init
vuex的源码一些理解
使用nginx控制ElasticSearch访问权限
使用python的scrapy来编写一个爬虫
再见 Docker,是时候拥抱下一代容器工具了
前端工具集(辅助工具、开发工具、技术栈、学习网站)
剖析ElasticSearch基础分布式架构
剖析ElasticSearch核心概念,NRT,索引,分片,副本等
原型链
推荐几款Linux下比Notepad++好的编辑器软件
搭了一个 wordpress 站点
收集整理的一些前端资源
浏览 GitHub 太卡了?教你两招!
用最简单的话告诉你什么是ElasticSearch
网络是怎样连接的?从浏览器输入URL开始
解决ChromeDriver安装与配置问题
**游记/杂记**
a
a
a
b
c
c
b
a
a
x
s
a
c
network
https
vue-src
index
_posts
hello
about
index
coc
index
menu
index
perf
index
support-vuejs
index
v2
api
index
cookbook
adding-instance-properties
avoiding-memory-leaks
client-side-storage
creating-custom-scroll-directives
debugging-in-vscode
dockerize-vuejs-app
editable-svg-icons
form-validation
index
packaging-sfc-for-npm
practical-use-of-scoped-slots
serverless-blog
unit-testing-vue-components
using-axios-to-consume-apis
examples
commits
deepstream
elastic-header
firebase
grid-component
hackernews
index
modal
select2
svg
todomvc
tree-view
guide
class-and-style
comparison
components
components-custom-events
components-dynamic-async
components-edge-cases
components-props
components-registration
components-slots
computed
conditional
custom-directive
deployment
events
filters
forms
index
installation
instance
join
list
migration
migration-vue-router
migration-vuex
mixins
plugins
reactivity
render-function
routing
single-file-components
ssr
state-management
syntax
team
transitioning-state
transitions
typescript
unit-testing
search
index
style-guide
index

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。 本文链接:https://blog.csdn.net/weixin_42508908/article/details/85986029 解决使用selenium自动控制浏览器找不到Chromedriver

最近学习爬虫过程中使用了selenium模块通过调用Chromedriver来实现自动控制Chrome,但其中遇到一些问题,在此总结。

首先,下载ChromeDriver时一定要对应好自己的浏览器版本,下载链接:http://npm.taobao.org/mirrors/chromedriver/

将下载好的ChromeDriver保存至Chrome浏览器的安装文件夹下

然后将ChromeDriver的路径配置到环境变量Path中,此时正常情况下调用ChromeDriver应该可以正常使用,

from selenium import webdriver

browser = webdriver.Chrome() browser.get('http://www.baidu.com/') 1 2 3 4 或者

from selenium import webdriver

options = webdriver.ChromeOptions() #options.add_argument('user-agent="Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36"') driver = webdriver.Chrome(chrome_options=options) driver.get('https://www.baidu.com/') 1 2 3 4 5 6 但有的电脑即使配置完环境变量依旧不能正常使用,看了其他博主所写,有的建议将ChromeDriver放置在python的安装目录以及工作目录下,结果是依然不起作用,产生报错:WebDriverException: Message: unknown error: cannot find Chrome binary那就只能采用设置路径的方法进行调用,如下:

from selenium import webdriver

browser = webdriver.Chrome('你的Chromedriver路径') browser.get('http://www.baidu.com/') 1 2 3 4 或

from selenium import webdriver

options = webdriver.ChromeOptions() #options.binary_location = r'你的Chrome安装路径' #options.add_argument('user-agent="Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36"') driver = webdriver.Chrome(chrome_options=options,executable_path=r'你的Chromedriver路径') driver.get('https://www.baidu.com/') 1 2 3 4 5 6 7 完美解决

———————————————— 版权声明:本文为CSDN博主「weixin_42508908」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/weixin_42508908/article/details/85986029

点赞(0) 阅读(136) 举报