• selenium启动Edge浏览器


    Edge的启动方式与之前的启动有些差异

    from selenium import webdriver
    from msedge.selenium_tools import EdgeOptions
    from msedge.selenium_tools import Edge
    
    def TransByEdge():
        edge_options = EdgeOptions()
        edge_options.use_chromium = True
        # 设置无界面模式,也可以添加其它设置
        # edge_options.add_argument('headless')
        # driver = Edge(options=edge_options)
        # edge_options = Options()
        prefs = {
            "translate": {"enabled": "true"},
            "translate_whitelists": {"zh-CN": "en"}
    
        }
        edge_options.add_argument('--start-maximized')
        edge_options.add_argument(
            "--user-data-dir="+r"C:UsersAdministratorAppDataLocalMicrosoftEdgeUser Data")
        edge_options.add_experimental_option("prefs", prefs)
        edge_driver = r"F:Anaconda3msedgedriver.exe"
        # C:SoftwaresAnaconda3chromedriver.exe
        # chrome_driver = r"C:ProgramDataAnaconda3msedgedriver.exe"
        driver = Edge(options=edge_options, executable_path=edge_driver)
        # get直接返回,不再等待界面加载完成
        desired_capabilities = DesiredCapabilities.EDGE
        desired_capabilities["pageLoadStrategy"] = "none"
        driver.get("https://weixin.sogou.com/")
        time.sleep(3)
        driver.close()
        driver.quit()

    需要 msedgedriver.exe  下载 https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/#downloads

    pip install msedge-selenium-tools

    依赖参考 https://www.cnblogs.com/lixuelong/p/14451608.html

  • 相关阅读:
    k近邻算法
    密码技术小总结
    编码的简单总结
    icmp dos和arp dos 攻击模拟实验
    WPA简单抓包分析
    Iptables实验
    Rabin简单加解密
    response响应数据
    浮动——小米手机案例
    ServletRequest请求详解
  • 原文地址:https://www.cnblogs.com/fly-kaka/p/14892794.html
Copyright © 2020-2023  润新知