空控制台输出Python

发布于 2025-02-13 10:16:42 字数 630 浏览 1 评论 0原文

我添加并使用了Undetected_chromedriver库,此后该程序停止工作。我做错了吗? 在控制台中没有写任何东西

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium import webdriver
import undetected_chromedriver as uc

options = webdriver.ChromeOptions() 
options.add_argument("start-maximized")
service = Service(executable_path="path")
driver = uc.Chrome(options=options, service=service)

driver.get("link")

接下来是该程序的代码,但是效果很好

控制台图像

I added and used undetected_chromedriver library, and after that the program stopped working. Did I do something wrong? Nothing is written in the console

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium import webdriver
import undetected_chromedriver as uc

options = webdriver.ChromeOptions() 
options.add_argument("start-maximized")
service = Service(executable_path="path")
driver = uc.Chrome(options=options, service=service)

driver.get("link")

Next comes the code of the program, but it worked well

Console image

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

太阳男子 2025-02-20 10:16:42

我相信在较新的UC版本中,它带有Chromeoptions,因此您无需使用硒。

import undetected_chromedriver as uc

options = uc.ChromeOptions() 
driver = uc.Chrome(options=options, version_main=94) #Choose correct version
driver.get('link')

I believe in the newer version of uc it comes with chromeoptions so you don't need to use selenium.

import undetected_chromedriver as uc

options = uc.ChromeOptions() 
driver = uc.Chrome(options=options, version_main=94) #Choose correct version
driver.get('link')
一瞬间的火花 2025-02-20 10:16:42

我从来没有弄清楚这些选择,但是问题在于路径。您需要使用driver_executable_path =“”。并添加模块导入检查如果__name__ =='__ main __':,然后将所有代码放在那里。现在该程序看起来像这样:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium import webdriver
import undetected_chromedriver as uc

if __name__ == '__main__':
    options = webdriver.ChromeOptions() #or options = uc.ChromeOptions()
    options.add_argument("start-maximized")
    driver = uc.Chrome(options=options, driver_executable_path="path")

    driver.get("link")

I never figured out the options, but the problem was with the path. You need to use driver_executable_path="". And add the module import check if __name__ == '__main__':, and put all the code there. Now the program looks like this:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
from selenium import webdriver
import undetected_chromedriver as uc

if __name__ == '__main__':
    options = webdriver.ChromeOptions() #or options = uc.ChromeOptions()
    options.add_argument("start-maximized")
    driver = uc.Chrome(options=options, driver_executable_path="path")

    driver.get("link")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文