diff --git a/conf/config.yaml b/conf/config.yaml index 5e24d70..eed3f26 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -4,5 +4,5 @@ SERVER: reconnect_interval: 3 VERSION: - code: 87 - name: 1.9.7 \ No newline at end of file + code: 88 + name: 1.9.8 \ No newline at end of file diff --git a/core/callback.py b/core/callback.py index 066ea1d..b3b7dcd 100644 --- a/core/callback.py +++ b/core/callback.py @@ -48,6 +48,12 @@ class CallBack(): body={'event': 'changeSucceed', 'reason': reason, 'data': data} ) + def changeingIn(self, email): + user_obj = models.UserList.get(email=email) + if user_obj: + models.UserList.remove(email=user_obj.email) + return + def onLoggingIn(self, email, password, cookie, user_agent=None, proxy=None): user_obj = models.UserList.get(email=email) if not user_obj: diff --git a/core/monitor.py b/core/monitor.py index bc24cef..775eb34 100644 --- a/core/monitor.py +++ b/core/monitor.py @@ -85,6 +85,7 @@ class Monitor(callback.CallBack): return client.info() else: try: + self.changeingIn(email) # 转环境的话清理缓存 result, email, password, cookie, user_agent = self.selenium_login(email, password, cookie) if result: self.onChangSucceed(email, '匹配设备指纹成功', @@ -135,10 +136,11 @@ class Monitor(callback.CallBack): chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--no-sandbox') # root用户不加这条会无法运行 chrome_options.add_argument('--headless') # 增加无界面选项 + chrome_options.add_argument('--proxy-server=http://8.210.170.163:24000') # 设置随机代理 from utils.encpass import get_random_device deviceName = get_random_device() print(email, '终端设备', deviceName) - self.onChangEnv(email, 'changeCreatDevice', '创建登录环境...') + self.onChangEnv(email, 'changeCreatDevice', '创建登录环境') chrome_options.add_experimental_option("mobileEmulation", {"deviceName": deviceName}) mainUrl = "https://m.facebook.com/" if user_agent is None or user_agent == '': @@ -146,9 +148,9 @@ class Monitor(callback.CallBack): chrome_options.add_argument(f'user-agent="{user_agent}"') # 创建浏览器对象 browser = webdriver.Chrome(desired_capabilities=capabilities, options=chrome_options) - self.onChangEnv(email, 'changeInitFinger', '初始化设备指纹...') + self.onChangEnv(email, 'changeInitFinger', '初始设备指纹') if cookie is not None and cookie != '': - self.onChangEnv(email, 'changeInitCookies', '初始化cookies...') + self.onChangEnv(email, 'changeInitCookies', '初始化cookies') print(email, '导入cookie') browser.get(mainUrl) from utils.encpass import back_cookies @@ -178,7 +180,7 @@ class Monitor(callback.CallBack): print(email, '等待页面', browser.current_url) continue if 'save-device' in browser.current_url and 'checkpoint' not in browser.current_url: - self.onChangEnv(email, 'changeSaveFinger', '保存设备指纹...') + self.onChangEnv(email, 'changeSaveFinger', '保存设备指纹') print(email, '保存设备点击ok') browser.find_element_by_xpath('//*[@id="root"]/div[1]/div/div/div[3]/div[2]/form/div/button').click() # user_agent_ = browser.execute_script("return navigator.userAgent") # 获取ua头部 @@ -207,7 +209,7 @@ class Monitor(callback.CallBack): print('随机动作', action_list) for i, action in enumerate(action_list): print(email, action) - self.onChangEnv(email, 'changeMatching', f'匹配设备指纹{i}...') + self.onChangEnv(email, 'changeMatching', f'匹配设备指纹{i + 1}...') browser.find_element_by_name(action).click() browser.get('https://m.facebook.com/home.php') # time.sleep(random.randint(1, 3))