标题:selenium 无头为什么错误
取消只看楼主
Z89
Rank: 2
等 级:论坛游民
威 望:1
帖 子:77
专家分:32
注 册:2022-4-26
结帖率:75%
 问题点数:0 回复次数:0 
selenium 无头为什么错误
有头模式没有错误
程序代码:
from webdriver_manager.chrome import ChromeDriverManager
import time
from requestium import Session, Keys
ua ='Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36'
s = Session(webdriver_path=ChromeDriverManager().install(), default_timeout=15, browser='chrome')
ra = s.get('https://bbs.bccn.net/forum-246-1.html')
s.transfer_session_cookies_to_driver()  
s.driver.get('https://bbs.bccn.net/forum-246-1.html')
time.sleep(100)



启动无头模式却发生错误

程序代码:
from webdriver_manager.chrome import ChromeDriverManager
from selenium import webdriver
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support import expected_conditions as EC
import time
from requestium import Session, Keys
ua ='Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36'
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("user-agent={}".format(ua)) 
chrome_options.add_argument('--headless') # 啟動無頭模式
chrome_options.add_argument('--disable-gpu') # windowsd必須加入
s = Session(webdriver_path=ChromeDriverManager().install(), default_timeout=15, browser='chrome',chrome_options=chrome_options)
ra = s.get('https://bbs.bccn.net/forum-246-1.html')
s.transfer_session_cookies_to_driver()  
s.driver.get('https://bbs.bccn.net/forum-246-1.html')
time.sleep(100)
搜索更多相关主题的帖子: 错误 bccn chrome from import 
2022-12-04 20:49



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-510858-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.149072 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved