日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux实现selenium+chrome+chromedriver实现自动化脚本

發布時間:2023/12/31 linux 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux实现selenium+chrome+chromedriver实现自动化脚本 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

1. 安裝chrome

yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm

2. 安裝chromedriver

wget https://chromedriver.storage.googleapis.com/2.38/chromedriver_linux64.zip # 或者 wget http://npm.taobao.org/mirrors/chromedriver/2.41/chromedriver_linux64.zip

3. 裝好之后就地解壓:

unzip chromedriver_linux64.zip

4. 然后將解壓的chromedriver移動到 /usr/bin目錄下:

mv chromedriver /usr/bin/

5. 給與執行權限:

chmod +x /usr/bin/chromedriver

6. 檢查版本:

# 檢查 chromedriver驅動 版本 chromedriver -version#檢查 chrome 版本 google-chrome --version

7. 完善py文件中的 Chrome 啟動參數如下:

目測防止報錯:如

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
? (unknown error: DevToolsActivePort file doesn't exist)
? (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
? (Driver info: chromedriver=2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706),platform=Linux 4.18.0-147.5.1.el8_1.x86_64 x86_64)

?

chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--headless') chrome_options.add_argument('--no-sandbox') chrome_options.add_argument('--disable-gpu') chrome_options.add_argument('--disable-dev-shm-usage')

總結

以上是生活随笔為你收集整理的linux实现selenium+chrome+chromedriver实现自动化脚本的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。