实例化浏览器运行代码后,遇到了浏览器自动关闭的情况
from selenium import webdriver#实例化浏览器driver = webdriver.Chrome()#打开页面url = 'https://www.baidu.com'driver.get(url)
selenium在启动chrome时为了保证最快的运行效率,启动了一个裸浏览器,不带有任何插件和参数,需要手动配置参数
from selenium import webdriver#实例化浏览器options = webdriver.ChromeOptions()options.add_experimental_option('detach',True)driver = webdriver.Chrome(options=options)#打开页面url = 'https://www.baidu.com'driver.get(url)
设置参数后,浏览器就不会自动关闭了
确定删除《selenium chrome自动关闭问题》吗
暂无评论
2023-11-12
2023-11-02
2024-05-20
2024-05-17
2024-05-08
2024-05-02
2024-04-30
2024-04-29
2024-04-26