|
发表于 2021-2-2 17:42:23
|
显示全部楼层
- from msedge.selenium_tools import Edge, EdgeOptions
- MSEDGE_PATH = r"C:\Program Files (x86)\Microsoft\Edge Beta\Application\msedge.exe"
- MSEDGE_DRIVER_PATH = './msedgedriver.exe' #https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/
- def init_imitate_edge_driver() -> Edge:
- options = EdgeOptions()
- options.use_chromium = True
- options.binary_location = MSEDGE_PATH
- options.add_experimental_option('excludeSwitches', ['enable-automation'])
- driver = Edge(options=options, executable_path=MSEDGE_DRIVER_PATH)
- driver.execute_cdp_cmd(
- "Page.addScriptToEvaluateOnNewDocument", {
- "source":
- """
- Object.defineProperty(navigator, 'webdriver', {
- get: () => undefined
- })
- """
- })
- return driver
- if __name__ == "__main__":
- driver = init_imitate_edge_driver()
- driver.get('https://fishc.com.cn/thread-189822-1-1.html')
复制代码 |
|