Linux下安裝chrome和chromedriver

adong發表於2021-09-24
轉載 https://www.cnblogs.com/-wenli/p/14065728.html
**安裝chrome**

wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
yum install ./google-chrome-stable_current_x86_64.rpm
yum install mesa-libOSMesa-devel gnu-free-sans-fonts wqy-zenhei-fonts

**安裝chromedriver**

wget http://npm.taobao.org/mirrors/chromedriver/2.41/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
mv chromedriver /usr/bin/ chmod +x /usr/bin/chromedriver

**Python指令碼快速測試**

from selenium.webdriver.chrome.options import Options from selenium import webdriver
chrome_options = Options()

chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('blink-settings=imagesEnabled=false')
chrome_options.add_argument('--headless')

driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get('https://www.baidu.com')
print driver.page_source 
print driver.title
本作品採用《CC 協議》,轉載必須註明作者和本文連結
寫程式碼是一件趣事。

相關文章