diff --git a/browser_gateway/platform/douyin.py b/browser_gateway/platform/douyin.py index 537d428..52a90a5 100644 --- a/browser_gateway/platform/douyin.py +++ b/browser_gateway/platform/douyin.py @@ -38,6 +38,8 @@ from ..runtime import ALIAS_RE LOG = logging.getLogger("creatorhub.douyin") ORIGIN = "https://www.douyin.com" ORIGIN_URL = ORIGIN + "/" +# 扫码登录默认打开个人中心页:未登录访问会引导登录,登录后即停在账号个人中心。 +LOGIN_PAGE_URL = ORIGIN + "/user/self" LOGIN_ORIGINS = frozenset( {ORIGIN, "https://sso.douyin.com", "https://verify.snssdk.com", "https://verify.bytedance.com"} ) @@ -379,7 +381,7 @@ class DouyinBrowser: def login_qr(self, alias: str) -> BrowserLoginQRResponse: with self.connection(alias) as cdp: - navigation = cdp.command("Page.navigate", {"url": ORIGIN_URL}) + navigation = cdp.command("Page.navigate", {"url": LOGIN_PAGE_URL}) if ( not isinstance(navigation, dict) or not isinstance(navigation.get("frameId"), str) diff --git a/browser_gateway/test_gateway.py b/browser_gateway/test_gateway.py index ff58587..a8144ae 100644 --- a/browser_gateway/test_gateway.py +++ b/browser_gateway/test_gateway.py @@ -22,6 +22,7 @@ from .platform.douyin import ( DouyinBrowser, DouyinError, DouyinSubscription, + LOGIN_PAGE_URL, ORIGIN_URL, SubscriptionManager, ack_expression, @@ -848,6 +849,10 @@ class BrowserTests(unittest.TestCase): "Page.captureScreenshot", ], ) + self.assertEqual( + cdp.command.call_args_list[0].args, + ("Page.navigate", {"url": LOGIN_PAGE_URL}), + ) self.assertFalse(any("cookie" in expression.lower() for expression in cdp.evaluate.call_args.args)) def test_connect_selects_configured_target_from_large_mixed_list(self) -> None: