美文网首页工作生活
Selenium-请在微信客户端打开链接

Selenium-请在微信客户端打开链接

作者: Lutous | 来源:发表于2019-07-04 00:14 被阅读0次

    使用Selenium打开微信链接时,可能会遇到以上提示,解决方法如下:

    #设置屏幕尺寸
    WIDTH = 320
    HEIGHT = 640
    PIXEL_RATIO = 3.0
    
    #设置User-Agent ---重要
    UA = "Mozilla/5.0 (Linux; Android 4.1.1; GT-N7100 Build/JRO03C) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/35.0.1916.138 Mobile Safari/537.36 T7/6.3"
    
    #URL地址
    TEST_URL = "http://cbt.shangjin618.com/lianxin-botserver/openApi/gotoPsyBot?channel=02&"chnlCode=8BFE42DF24C45563B5EA6E82C61E9279F0AE5235BA5392B2698BDD374FEB391B274549C0F4BB1E94&unionId=1888"
    
    #设备信息
    mobile_emulation = 
    {
            "deviceMetrics": 
                    {
                            "width": WIDTH, 
                            "height": HEIGHT, 
                              "pixelRatio": PIXEL_RATIO
                    },
             "userAgent": UA
    }
    mobile_emulation = {"userAgent": UA}
    options = webdriver.ChromeOptions()
    options.add_experimental_option('mobileEmulation', mobile_emulation)
    
    driver = webdriver.Chrome(executable_path='chromedriver.exe', options=options)
    driver.get(TEST_URL)
    return driver
    

    相关文章

      网友评论

        本文标题:Selenium-请在微信客户端打开链接

        本文链接:https://www.haomeiwen.com/subject/qxtkhctx.html