diff --git a/README.md b/README.md index 363d980..43fea46 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ > 7天有效期,自动更新, 如果人满了可以加作者wx拉进群: yzglan,备注来自github.
-

8群二维码

+

9群二维码

@@ -115,6 +115,8 @@ ➡️➡️➡️ [常见问题](docs/常见问题.md) +抖音使用Playwright登录现在会出现滑块验证 + 短信验证,手动过一下 + ## 项目代码结构 ➡️➡️➡️ [项目代码结构说明](docs/项目代码结构.md) diff --git a/base/base_crawler.py b/base/base_crawler.py index 2ddf626..fa59055 100644 --- a/base/base_crawler.py +++ b/base/base_crawler.py @@ -56,13 +56,15 @@ class AbstractStore(ABC): async def store_creator(self, creator: Dict): pass + class AbstractStoreImage(ABC): - #TODO: support all platform + # TODO: support all platform # only weibo is supported # @abstractmethod async def store_image(self, image_content_item: Dict): pass + class AbstractApiClient(ABC): @abstractmethod async def request(self, method, url, **kwargs): @@ -71,7 +73,3 @@ class AbstractApiClient(ABC): @abstractmethod async def update_cookies(self, browser_context: BrowserContext): pass - - @abstractmethod - async def pong(self): - pass diff --git a/config/base_config.py b/config/base_config.py index 58779e1..7bab87a 100644 --- a/config/base_config.py +++ b/config/base_config.py @@ -19,7 +19,7 @@ IP_PROXY_PROVIDER_NAME = "kuaidaili" # 设置False会打开一个浏览器 # 小红书如果一直扫码登录不通过,打开浏览器手动过一下滑动验证码 # 抖音如果一直提示失败,打开浏览器看下是否扫码登录之后出现了手机号验证,如果出现了手动过一下再试。 -HEADLESS = True +HEADLESS = False # 是否保存登录状态 SAVE_LOGIN_STATE = True diff --git a/media_platform/douyin/client.py b/media_platform/douyin/client.py index 486b2f9..796ca74 100644 --- a/media_platform/douyin/client.py +++ b/media_platform/douyin/client.py @@ -86,10 +86,12 @@ class DOUYINClient(AbstractApiClient): headers = headers or self.headers return await self.request(method="POST", url=f"{self._host}{uri}", data=data, headers=headers) - @staticmethod - async def pong(browser_context: BrowserContext) -> bool: + async def pong(self, browser_context: BrowserContext) -> bool: + local_storage = await self.playwright_page.evaluate("() => window.localStorage") + if local_storage.get("HasUserLogin", "") == "1": + return True + _, cookie_dict = utils.convert_cookies(await browser_context.cookies()) - # todo send some api to test login status return cookie_dict.get("LOGIN_STATUS") == "1" async def update_cookies(self, browser_context: BrowserContext): diff --git a/media_platform/douyin/login.py b/media_platform/douyin/login.py index e48615e..d2f081f 100644 --- a/media_platform/douyin/login.py +++ b/media_platform/douyin/login.py @@ -73,8 +73,19 @@ class DouYinLogin(AbstractLogin): """Check if the current login status is successful and return True otherwise return False""" current_cookie = await self.browser_context.cookies() _, cookie_dict = utils.convert_cookies(current_cookie) + + for page in self.browser_context.pages: + try: + local_storage = await page.evaluate("() => window.localStorage") + if local_storage.get("HasUserLogin", "") == "1": + return True + except Exception as e: + utils.logger.warn(f"[DouYinLogin] check_login_state waring: {e}") + await asyncio.sleep(1) + if cookie_dict.get("LOGIN_STATUS") == "1": return True + return False async def popup_login_dialog(self): diff --git a/static/images/8群二维码.JPG b/static/images/8群二维码.JPG deleted file mode 100644 index b764722..0000000 Binary files a/static/images/8群二维码.JPG and /dev/null differ diff --git a/static/images/9群二维码.PNG b/static/images/9群二维码.PNG new file mode 100644 index 0000000..6ae94eb Binary files /dev/null and b/static/images/9群二维码.PNG differ