Linux install chrome、 Firefox、 Phantomjs

Linux下载火狐浏览器



Linux下载谷歌

  • 下载网站: https://www.google.com/chrome/

  • 安装:

    • Ubuntu安装:
    • CentOS安装:
      • 打开: sudo vi /etc/yum.repos.d/google-chrome.repo
      • 写入
      •   [google-chrome]
          name=google-chrome
          baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch
          enabled=1
          gpgcheck=1
          gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
        
      • 安装: sudo yum -y install google-chrome-stable --nogpgcheck
  • ChromeDriver下载地址: https://sites.google.com/a/chromium.org/chromedriver/downloads

  • 解压: unzip 文件

  • 移动到: /usr/bin

  • ERROR:

    • ERROR: … wrong permissions … 解决: sudo chmod 777 chromedriver
    • ERROR: … DevToolsActivePort file doesn’t exist …
      •   from selenium import webdriver
          from selenium.webdriver.chrome.options import Options
          chrome_options = Options()
          chrome_options.add_argument("--headless")
          # chrome_options.add_argument('--no-sandbox')
          driver = webdriver.Chrome(options=chrome_options)
          # driver = webdriver.Chrome(chrome_options=chrome_options)
          driver.set_page_load_timeout(300)
          driver.set_script_timeout(300)
          driver.get('http://www.baidu.com')
        


Ubuntu下载phantomjs

  • 更新源:sudo apt-get update

  • 下载:sudo apt-get install phantomjs

  • 查看版本: phantomjs --version

  • ERROR:

    • …Could not connect to display…Aborted…
      • 打开: sudo vi /etc/profile.d/aliases.sh
      • 添加:
        • #!/bin/bash
        • alias phantomjs=“xvfb-run phantomjs”
      • 执行: source /etc/profile && phantomjs
    • Service phantomjs unexpectedly exited. Status code was: -6
      •   from selenium import webdriver  
          from pyvirtualdisplay import Display  
          display = Display(visible=0, size=(800,600))  
          display.start()  
          driver = webdriver.PhantomJS()  
          driver.get("http://www.baidu.com")  
        
  • 注意:

    • 依赖包: sudo apt install xvfb
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章