對於谷歌Chrome32位版本,使用如下鏈接:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_i386.deb
對於64位版本可以使用如下鏈接下載:
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
下載完后,運行如下命令安裝。
sudo dpkg -i google-chrome*;
sudo apt-get -f install
可能出現的問題:
一:啟動Chrome瀏覽器
- # google-chrome
這時會報錯:
[31560:31560:0207/085601.085852:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
解決方法:
- # google-chrome --no-sandbox
仍會報錯:
root@node00:~# [0207/085735.495265:ERROR:nacl_helper_linux.cc(310)] NaCl helper process running without a sandbox!
Most likely you need to configure your SUID sandbox correctly
解決方法:
- # whereis google-chrome
- google-chrome: /usr/bin/google-chrome /usr/share/man/man1/google-chrome.1.gz
- # vim /usr/bin/google-chrome
將 exec -a "$0" "$HERE/chrome" "$@" 改為
exec -a "$0" "$HERE/chrome" "$@" --user-data-dir --no-sandbox
以后只要 google-chrome 就可以打開Chrome了
如果不行:可能就是缺少chromeDriver了
錯誤:
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.34.522913 (36222509aa6e819815938cbf2709b4849735537c),platform=Linux 4.10.0-42-generic x86_64)
解決辦法:
Start the Display before start the Chrome.
先執行一下兩句安裝命令(以ubuntu為例):
- pip install pyvirtualdisplay
- sudo apt-get install xvfb
然后添加如下代碼:
- from pyvirtualdisplay import Display
- display = Display(visible=0, size=(800, 800))
- display.start()
- driver = webdriver.Chrome()
驅動映射表:
https://blog.csdn.net/zhanghua_ting/article/details/79498152
安裝selenium
pip3 install selenium