Files
EveryPublish/xhs_uploader/xhs_login_qrcode.py
T
home@pookz.com b78f3900c3 1. add xhs pypi
2. fix xhs hashtag
3. qrcode login?
2024-06-13 00:12:10 +08:00

34 lines
953 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import datetime
import json
import qrcode
from time import sleep
from xhs import XhsClient
from xhs_uploader.main import sign_local, sign
# pip install qrcode
if __name__ == '__main__':
xhs_client = XhsClient(sign=sign, timeout=60)
print(datetime.datetime.now())
qr_res = xhs_client.get_qrcode()
qr_id = qr_res["qr_id"]
qr_code = qr_res["code"]
qr = qrcode.QRCode(version=1, error_correction=qrcode.ERROR_CORRECT_L,
box_size=50,
border=1)
qr.add_data(qr_res["url"])
qr.make()
qr.print_ascii()
while True:
check_qrcode = xhs_client.check_qrcode(qr_id, qr_code)
print(check_qrcode)
sleep(1)
if check_qrcode["code_status"] == 2:
print(json.dumps(check_qrcode["login_info"], indent=4))
print("当前 cookie:" + xhs_client.cookie)
break
print(json.dumps(xhs_client.get_self_info(), indent=4))