selenium 使用隐藏模式打开浏览器


'''
option=webdriver.ChromeOptions()
option.add_argument('headless') # 设置option
driver = webdriver.Chrome(chrome_options=option)  # 调用带参数的谷歌浏览器
'''

from selenium import webdriver
option = webdriver.ChromeOptions()
option.add_argument('headless') # 设置option
driver = webdriver.Chrome(chrome_options=option) # 调用带参数的谷歌浏览器
driver.get("http://www.baidu.com")
elem = driver.find_element_by_css_selector("span input[type='submit']")
if elem :
    print("打开百度页面成功")
else:
    print('打开百度页面失败')

driver.quit()

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM