工作生活

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

2019-07-04  本文已影响0人  Lutous

使用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
上一篇下一篇

猜你喜欢

热点阅读