Skip to content
This repository has been archived by the owner on Nov 9, 2024. It is now read-only.

Commit

Permalink
解决了一个潜在的导致获取不到Cookie的BUG
Browse files Browse the repository at this point in the history
  • Loading branch information
ljpkok committed May 20, 2024
1 parent 1541ae5 commit a5a512a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/jd_cookie_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,19 @@ async def get_jd_cookie() -> (bool, str):
# 在隐私上下文中打开新的页面
page = await context.newPage()
await page.setViewport({'width': 1000, 'height': 800})
await page.goto('https://home.m.jd.com/myJd/home.action', {'timeout': 1000 * 60})
await page.goto('https://home.m.jd.com/myJd/newhome.action', {'timeout': 1000 * 60})

# 等待页面加载完成
await page.waitForNavigation({'waitUntil': 'domcontentloaded'})

# 检查页面是否跳转到登录页面
if 'plogin.m.jd.com' in page.url:
print("Redirected to login page. Logging in...")

# 等待页面加载完成
await page.waitForNavigation({'waitUntil': 'domcontentloaded'})

await page.goto('https://home.m.jd.com/myJd/newhome.action', {'timeout': 1000 * 60})

try:
await page.waitFor(1000)
Expand Down

0 comments on commit a5a512a

Please sign in to comment.