diff --git a/Get-JDCookie.py b/Get-JDCookie.py index 2a5fbec..896dff4 100644 --- a/Get-JDCookie.py +++ b/Get-JDCookie.py @@ -1,5 +1,6 @@ #!/usr/bin/env python # -*- coding:utf-8 -*- +__author__ = "Huaisha2049" import asyncio from random import random from socket import timeout @@ -27,13 +28,18 @@ def find_cookie(cookies): async def main(): """使用pyppeteer库来登录京东、并获取cookie """ - print('请在弹出的网页中登录账号、推荐使用账户短信验证码的形式登录。') browser = await launch(headless=False, dumpio=True, autoClose=False, args=['--no-sandbox', '--window-size=1000,800', '--disable-infobars']) # 进入有头模式 context = await browser.createIncognitoBrowserContext() # 隐身模式 + + # 关闭默认打开的第一个标签页 + pages = await browser.pages() + if pages: + await pages[0].close() + page = await context.newPage() # 打开新的标签页 await page.setViewport({'width': 1000, 'height': 800}) # 页面大小一致 - await page.goto('https://home.m.jd.com',{'timeout': 1000*60}) # 访问主页、增加超时解决Navigation Timeout Exceeded: 30000 ms exceeded报错 + await page.goto('https://home.m.jd.com/myJd/home.action',{'timeout': 1000*60}) # 访问主页、增加超时解决Navigation Timeout Exceeded: 30000 ms exceeded报错 await page.waitFor(1000) elm = await page.waitForXPath('//*[@id="myHeader"]',timeout=0) # 通过判断用户头像是否存在来确定登录状态 @@ -50,4 +56,25 @@ async def main(): if __name__== "__main__": + aaa = """ + +    へ     /| +   /\7    ∠_/ +   / │   / / +  │ Z _,< /   /`ヽ +  │     ヽ   /  〉 +   Y     `  /  / +  ●  ●  〈  / +  ()  へ    | \〈 +   > _  ィ  │ // +   / へ   / <| \\ +   ヽ_  (_/  │// +   7       |/ +   >―r ̄ ̄`―_ + + 使用说明:在弹出的网页中登录账号、推荐使用账户短信验证码的形式登录 + 问题反馈:https://github.com/huaisha1224 + 作者:怀沙2049 +""" + print(aaa) asyncio.get_event_loop().run_until_complete(main()) #调用 diff --git a/exe/Get-JDCookie.exe b/exe/Get-JDCookie.exe index 812437e..b7c8e44 100644 Binary files a/exe/Get-JDCookie.exe and b/exe/Get-JDCookie.exe differ