edge的无头浏览器代码真的是太难找了,全都是谷歌的,最后终于被我找到了,也不管他啥意思了,黏贴上就完事了。Python的库真的是太多了。每一个方法感觉都要用一个库。也怪不得说简单呢,就是学起来麻烦。吐槽完了代码在下面
from selenium import webdriver
from msedge.selenium_tools import EdgeOptions
from msedge.selenium_tools import Edge
edge_options = EdgeOptions()
edge_options.use_chromium = True
# 设置无界面模式,也可以添加其它设置
edge_options.add_argument('headless')
#规避被检测到的风险
edge_options.add_experimental_option("excludeSwitches", ["enable-automation"])
driver = Edge(options=edge_options)
r = driver.get('https://www.baidu.com')
print(driver.page_source)
driver.quit()