bugfix: 修复手机模拟器过期的问题

This commit is contained in:
chenwj113 2023-07-24 22:27:27 +08:00
parent c56f6ee5de
commit 96346841e5
1 changed files with 4 additions and 4 deletions

View File

@ -8,7 +8,7 @@ from selenium.webdriver import ChromeOptions
class Chrome(object): class Chrome(object):
def __init__(self, mobile=True, headless=True): def __init__(self, mobile=True, headless=True):
self.mobile_emulation = {'deviceName': 'iPad Mini'} self.mobile_emulation = {'deviceName': 'iPhone 12 Pro'}
self.mobile = mobile self.mobile = mobile
self.headless = headless self.headless = headless
@ -24,7 +24,7 @@ class Chrome(object):
chrome_options.add_argument('--headless') chrome_options.add_argument('--headless')
if self.mobile: if self.mobile:
chrome_options.add_experimental_option("mobileEmulation", self.mobile_emulation) chrome_options.add_experimental_option("mobileEmulation", self.mobile_emulation)
chrome_options.add_argument('user-agent="Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1"') # chrome_options.add_argument('user-agent="Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1"')
start_chrome("https://youdian.jindianle.com/", options=chrome_options) start_chrome("https://youdian.jindianle.com/", options=chrome_options)
click(Text("您尚未登录,点击登录")) click(Text("您尚未登录,点击登录"))
click(Text("密码登录")) click(Text("密码登录"))
@ -264,8 +264,8 @@ with Chrome() as chrome:
# chrome.balance() # chrome.balance()
# 组选 # 组选
# result = ['039', '048', '049', '138', '139', '147', '237', '238', '246', '247'] # result = ['039', '048', '049', '138', '139', '147', '237', '238', '246', '247']
result = ['237', '057', '129', '256', '247', '049', '067', '257', '059', '267', '069', '078', '258', '058', '357'] result = ['258', '256', '156', '247', '067']
chrome.pls(result = result, multiple=1, save_result=False) chrome.pls(result = result, multiple=1, save_result=True)
# 直选 # 直选
# result = ['246', '264', '291', '219', '169'] # result = ['246', '264', '291', '219', '169']
# chrome.pls(result=result, is_group=False) # chrome.pls(result=result, is_group=False)