硒+wsl2

2024-10-16 22:32:29 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试设置python selenium来处理我的WSL2(Kali)。 我跟随这篇文章https://www.gregbrisebois.com/posts/chromedriver-in-wsl2/

在终端中运行“谷歌浏览器”会返回一个正常工作的浏览器

尝试运行此测试脚本会导致出现一个浏览器窗口,但在driver=webdriver.Chrome()运行后,没有任何内容加载到该窗口,也没有代码

from pyvirtualdisplay import Display
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options
import time

print('starting')

driver = webdriver.Chrome()
driver.get('https://www.google.com')

print('Worked')
driver.close()

这是脚本返回但从不停止加载的浏览器 enter image description here


Tags: fromhttpsimport脚本comwwwdriverselenium