正在显示
2 个修改的文件
包含
14 行增加
和
2 行删除
| @@ -132,6 +132,17 @@ class Monitor(callback.CallBack): | @@ -132,6 +132,17 @@ class Monitor(callback.CallBack): | ||
| 132 | self.onLoggingError(email, str(err)) | 132 | self.onLoggingError(email, str(err)) |
| 133 | raise err | 133 | raise err |
| 134 | 134 | ||
| 135 | + def close_selenium(self, email, browser): | ||
| 136 | + """ | ||
| 137 | + 关闭浏览器 | ||
| 138 | + """ | ||
| 139 | + self.onChangEnv(email, 'changeError', '登录失败:change超时70s,关闭浏览器') | ||
| 140 | + try: | ||
| 141 | + browser.close() | ||
| 142 | + except Exception as e: | ||
| 143 | + print('close_selenium', e) | ||
| 144 | + return | ||
| 145 | + | ||
| 135 | def selenium_login(self, email, password, cookie=None, user_agent=None): | 146 | def selenium_login(self, email, password, cookie=None, user_agent=None): |
| 136 | """ | 147 | """ |
| 137 | 如果为号密登录,则使用浏览器获取cookie | 148 | 如果为号密登录,则使用浏览器获取cookie |
| @@ -160,6 +171,7 @@ class Monitor(callback.CallBack): | @@ -160,6 +171,7 @@ class Monitor(callback.CallBack): | ||
| 160 | chrome_options.add_argument(f'user-agent="{user_agent}"') | 171 | chrome_options.add_argument(f'user-agent="{user_agent}"') |
| 161 | # 创建浏览器对象 | 172 | # 创建浏览器对象 |
| 162 | browser = webdriver.Chrome(desired_capabilities=capabilities, options=chrome_options) | 173 | browser = webdriver.Chrome(desired_capabilities=capabilities, options=chrome_options) |
| 174 | + threading.Timer(70, self.close_selenium, args=[email, browser]).start() | ||
| 163 | try: | 175 | try: |
| 164 | self.onChangEnv(email, 'changeInitFinger', '初始设备指纹') | 176 | self.onChangEnv(email, 'changeInitFinger', '初始设备指纹') |
| 165 | if cookie is not None and cookie != '': | 177 | if cookie is not None and cookie != '': |
-
请 注册 或 登录 后发表评论