def login_with_cookies(self, cookies): # cookies = self.driver.get_cookies() # self.driver.get(URL_WENDA) self._cookies = self.driver.get_cookies() c = self._cookies + cookies self.headers['cookie'] = format_cookies(c) # self.stop() save_cookie(COOKIE_FILE, self.headers['cookie']) return self.headers
def login(self,username=USERNAME,password=PASSWORD): self.username = username self.password = password self.driver.get(URL_LOGIN_HOME) self.__account_input() self._slider_img_download() self._validate_and_drag() time.sleep(2) cookies = self.driver.get_cookies() self.driver.get(URL_WENDA) time.sleep(2) self._cookies = self.driver.get_cookies() c = self._cookies + cookies self.headers['cookie'] = format_cookies(c) logger.info(f'成功滑动登陆!cookie:{self.headers["cookie"]}') self.stop() save_cookie(COOKIE_FILE,self.headers['cookie']) return self.headers