1. 安装 selenium

pip3 install selenium
pip3 安装参考

2. 安装 ChromeDriver

yum install chromedriver.x86_64

3. 安装 Chrome

  1. 配置源,终端复制执行下面的代码
cat << EOF > /etc/yum.repos.d/google-chrome.repo
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl.google.com/linux/linux_signing_key.pub
EOF
  1. 安装 chrome
    yum install google-chrome-stable

4.测试

from selenium import webdriver
driver = webdriver.Chrome()
driver.get('http://www.baidu.com/')
print( driver.title )
driver.quit()

如果遇到错误"unknown error: DevToolsActivePort file doesn't exist " 使用以下配置

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--headless')
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get('http://www.baidu.com/')
print( driver.title )
driver.quit()

phantomjs

1.下载地址:http://phantomjs.org/download.html

2.文件名:phantomjs-2.1.1-linux-x86_64.tar.bz2

# 下载好后进行解压(由于是bz2格式,要先进行bzip2解压成tar格式,再使用tar解压)
yum -y install bzip2.x86_64
bzip2 -d phantomjs-2.1.1-linux-x86_64.tar.bz2

# 再使用tar进行解压到/usr/local/目录下边
tar xvf phantomjs-2.1.1-linux-x86_64.tar -C /usr/local/

# 安装依赖软件
yum -y install wget fontconfig

# 重命名(方便以后使用phantomjs命令)
mv /usr/local/phantomjs-2.1.1-linux-x86_64/ /usr/local/phantomjs

# 最后一步就是建立软连接了(在/usr/bin/目录下生产一个phantomjs的软连接,/usr/bin/是啥目录应该清楚,不清楚使用 echo $PATH查看)
ln -s /usr/local/phantomjs/bin/phantomjs /usr/bin/
复制代码
到这一步就安装成功了,接下来测试一下(经过上面建立的软连接,你就可以使用了,而且是想使用命令一样的进行使用哦!):

[root@localhost ~]# phantomjs
phantomjs>

phantomjs> phantom.exit();

 

linux安装selenium+chrome+phantomjs的更多相关文章

  1. arm树莓派Raspbian 下安装selenium+chrome

    arm树莓派Raspbian 下安装selenium+chrome 安装selenium pip3 install selenium 安装chromedriver sudo apt-get insta ...

  2. linux无界面模式安装selenium+chrome+chromedriver并成功完成脚本(亲测可用)

    环境:docker centos 7.4 能通外网 写好的selenium脚本. 具体步骤: 一:安装selenium  这是最简单的 直接利用 pip3 install selenium 二 安装c ...

  3. Linux配置Selenium+Chrome+Java实现自动化测试

    1.安装chrome sudo apt-get install libxss1 libappindicator1 libindicator7 wget https://dl.google.com/li ...

  4. arm 环境下安装selenium+chrome

    1.  升级软件 apt-get update 2. 安装pip apt-get install python3-pip 3. 安装selenium pip3 install selenium .4. ...

  5. Linux配置Selenium+Chrome+Python

    ---恢复内容开始--- 最近一个月没有更新博客了.最近都在复习LINUX与PYTHON知识.决定以后在LINUX环境下学习新知识. 包括后期的框架学习与平台知识方面. 直接记录今天下午的学习成果. ...

  6. Deb版本Linux配置Selenium+Chrome+Java实现自动化测试

    1.安装chrome sudo apt-get install libxss1 libappindicator1 libindicator7 wget https://dl.google.com/li ...

  7. ubuntu中如何安装selenium+chrome(headless)无界面浏览器?

    selenium是一个Web的自动化测试工具,它可以根据我们的指令,让浏览器自动加载页面,获取需要的数据,甚至页面截屏,或者判断网站上某些动作是否发生.但是它自身不带浏览器,不支持浏览器的功能,因此它 ...

  8. Selenium+Chrome/phantomJS模拟浏览器爬取淘宝商品信息

    #使用selenium+Carome/phantomJS模拟浏览器爬取淘宝商品信息 # 思路: # 第一步:利用selenium驱动浏览器,搜索商品信息,得到商品列表 # 第二步:分析商品页数,驱动浏 ...

  9. 在linux中安装selenium+chrome

    主要参照百度的一些内容加上自己的实际操作,对自己遇到的几个问题进行总结: 第一个问题:安装selenium---sudo pip install selenium 显示:You are using p ...

随机推荐

  1. iOS 钥匙串存储用户数据

    参考: http://www.jianshu.com/p/f6d40065bb6c #import <Foundation/Foundation.h> #import <Securi ...

  2. vue中使用Base64和md5和rsa

    https://blog.csdn.net/benben513624/article/details/88113459(copy) https://www.cnblogs.com/myfate/p/1 ...

  3. 【php】记录一次生产环境bug的调试

    参考链接: [php调试利器 -- xdebug]https://www.cnblogs.com/anyeshe/p/5746404.html [PHP 后端调试输出方法(笨办法)]https://b ...

  4. 解决PHP乱码

    如果你的PHP页面出现了乱码,之需要在页面的开始处加入下面代码就可以了. <?php header("content-type:text/html;charset=utf-8" ...

  5. Python——接口类、抽象类

    建立一个接口类.抽象类的规范 from abc import abstractmethod,ABCMeta class Payment(metaclass=ABCMeta): # 元类 默认的元类 t ...

  6. 源码编译安装php7

    现在新启的项目都是采用php7了,无奈很多Linux发行版中还是php5 第三方php7源在自己本机上用用到无所谓,放到正式环境上还是有点不放心 其实编译安装也就几分钟,麻烦的是各种依赖 先删除老版本 ...

  7. 金融量化分析【day112】:股票数据分析Tushare2

    目录 1.使用tushare包获取某股票的历史行情数据 2.使用pandas包计算该股票历史数据的5日局限和60日均线 3.matplotlib包可视化历史数据的收盘价和历史均线 4.分析输出所有金叉 ...

  8. NOI-OJ 2.2 ID:8758 2的幂次方表示

    思路 可以把任意一个数转化为2^a+2^b+2^c+...+2^n 例如137的二进制为10001001,这就等效于2^7+2^3+2^0 以上结果如何通过程序循环处理呢?需要把数字n分解为上述公式, ...

  9. Spring IOC容器对bean的生命周期进行管理的过程

    1.通过构造器或者工厂方法创建bean的实例 2.为bean的属性设置值和对其他bean的引用 3.将bean的实例传递给bean的后置处理器BeanPostProcessor的postProcess ...

  10. [数学杂志]AML

    Copied from: http://www.elsevier.com/journals/applied-mathematics-letters/0893-9659/guide-for-author ...