centos8python+selenium环境搭建
安装CentOS 8桌面版
系统镜像名 CentOS-8.2.2004-x86_64-dvd1.iso
若无GUI,需安装
python;gutter:true;">sudo dnf groupinstall "Server with GUI"
安装vnc-server
sudo dnf install tigervnc-server -y
vncpasswd # 设置密码
vncserver # 启动,报错了
dnf groupinstall "gnome-desktop"
cp /lib/systemd/system/vncserver@.service /etc/systemd/vncserver@:1.service
vim /etc/systemd/vncserver@:1.service # 将<USER> 改为要使用远程的用户名,如root
vim /usr/lib/systemd/system/vncserver@.service # 将<USER> 改为要使用远程的用户名,如root
systemctl daemon-reload
systemctl start vncserver@:1.service
systemctl status vncserver@:1.service
systemctl enable vncserver@:1.service
参考:
https://zhuanlan.zhihu.com/p/126368045
https://www.cnblogs.com/zhengjinsheng/p/12888557.html
修改分辨率
vncserver -geometry 1920x1080
vncserver -list
vncserver -kill :1
安装Chrome,安装完在root下启动需加参数
google-chrome-stable --no-sandbox
sudo dnf -y install wgetwget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
sudo dnf localinstall google-chrome-stable_current_x86_64.rpm
pip3 install selenium
下载对应浏览器的driver后,放到系统环境变量path目录下,如/usr/local/bin
https://chromedriver.chromium.org/
或 http://npm.taobao.org/mirrors/chromedriver/
https://github.com/mozilla/geckodriver/releases/
测试是否能打开浏览器了
from selenium import webdriverbrowser = webdriver.Chrome()
# browser = webdriver.Firefox()
browser.get("http://www.baidu.com/")
以上是 centos8python+selenium环境搭建 的全部内容, 来源链接: utcz.com/z/530830.html