Python配置Selenium+Chrome环境和Selenium+PhantomJS环境
来源:互联网 发布:java有没有二叉树类 编辑:程序博客网 时间:2024/05/16 07:09
配置步骤
1.在pycharm编译其中按上一篇文章简单粗暴:使用pycharm安装对应的Python版本第三方包,在包的搜索窗口输入Selenium,然后点击Install Package即可。
2.下载最新版本的Chrome浏览器安装
3.下载最新版本ChromeDrive.exe
可进入以下网址进行下载
http://chromedriver.storage.googleapis.com/index.html
下载下来为一个压缩包文件,解压缩,得到chromedrive.exe
4.将下载的最新版本的chromedrive.exe拷贝到你的python3.x的安装目录,或者是C:Windows目录下
整个Selenium+Chrome的环境配置就完成了
我的python3.x安装路劲为:C:\Users\Administrator\AppData\Local\Programs\Python\Python35\
到这里整个Selenium+Chrome环境配置就完成了,快使用下列代码打开你的浏览器吧
#掉用第三方包selenium打开浏览器登陆 driver=webdriver.Chrome()#打开chrome #driver.implicitly_wait(30) driver.get(tieziUrl)#登陆两次 driver.get(tieziUrl) #print(driver.page_source) html=driver.page_source#将浏览器执行后的源代码赋给html driver.close() # Close the current window. driver.quit()#关闭chrome浏览器
5.上面代码每次都会打开一次Chrome浏览器,但是假如我们循环次数较多时,每次都打开一次浏览器会干扰我们在桌面上的其他工作,所以这里介绍一个无界面的浏览器包PhantomJS
首先在官网下载地址:http://phantomjs.org/download.html
或者CSDN下载频道以往版本:http://download.csdn.net/detail/tylanbin/7211747
然后得到压缩包,解压,将里面的PhantomJS.exe文件复制到你的python安装路径或者C:windows下,只要是系统的环境path目录都行
然后只需要把上面driver=webdriver.Chrome()改成driver=webdriver.PhantomJS()即可
- Python配置Selenium+Chrome环境和Selenium+PhantomJS环境
- python selenium环境配置Firefox和Chrome
- [python]Selenium+PhantomJS环境配置教程
- linux爬虫开发环境配置python+selenium+phantomJS
- python + selenium + chrome环境搭建
- selenium+python 环境配置
- Python Selenium环境配置
- Selenium+Chrome(PhantomJs) Python爬虫
- [Anaconda2]Selenium+PhantomJS环境搭建
- Selenium WebDriver + Python 环境配置
- W32 python+selenium环境配置
- 配置环境 appium+Python+selenium
- PhantomJS、Selenium、Chrome驱动的mac版安装和配置
- python eclipse 插件安装 及BeautifulSoup requests selenium在线安装 PhantomJS 安装 环境配置
- 数据抓取的艺术:Selenium+Phantomjs数据抓取环境配置
- selenium设置phantomjs和chrome请求头
- selenium web 自动化环境搭建(Windows7 环境, Chrome, Python)
- Python + Selenium环境搭建
- 微信小程序通过本地缓存实现点赞功能
- Android Intent机制详解
- 润乾报表中的排序
- java模拟多线程socket通信
- 代理模式的理解
- Python配置Selenium+Chrome环境和Selenium+PhantomJS环境
- 数组的倒序输出
- Zookeeper+Dubbo+Spring整合
- 【Js】easyUI时间控件datebox计算时间差
- 导出excel的数据拼接成sql导入到数据库中
- org.hibernate.LazyInitializationException
- hdu 2955 01背包
- JSP+Servlet培训班作业管理系统[0]-功能设计
- 链表面试题Java实现【重要】