Skip to content

Commit

Permalink
更新 3.5 版本
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeanAmier committed Jul 28, 2023
1 parent 80b8b8c commit 422fc1b
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions src/Parameter.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from hashlib import md5
from pathlib import Path
from random import randint
from string import ascii_letters
from string import digits
from time import time
from urllib.parse import urlencode

from execjs import compile
# from execjs import compile
from requests import exceptions
from requests import post

Expand Down Expand Up @@ -231,27 +230,27 @@ def get_x_bogus(
query, version, user_agent[self.__index[version]], timestamp)


class XBogus:
"""代码参考: https://github.com/B1gM8c/X-Bogus/blob/main/X-Bogus.js"""

def __init__(self, pc_js=None, app_path=None):
self.pc_path = Path(pc_js or "./static/js/X-Bogus.js")
self.pc_file = self.pc_path.open()
self.pc_js = compile(self.pc_file.read())
self.app_path = Path(app_path or "")
self.app_file = None
self.app_js = None

@run_time
def get_x_bogus(self, query: dict, user_agent: str, platform="PC"):
if platform == "PC":
return self.pc_js.call("sign", urlencode(query), user_agent)
elif platform == "APP":
return ""
raise ValueError

def close(self):
self.pc_file.close()
# class XBogus:
# """代码参考: https://github.com/B1gM8c/X-Bogus/blob/main/X-Bogus.js"""
#
# def __init__(self, pc_js=None, app_path=None):
# self.pc_path = Path(pc_js or "./static/js/X-Bogus.js")
# self.pc_file = self.pc_path.open()
# self.pc_js = compile(self.pc_file.read())
# self.app_path = Path(app_path or "")
# self.app_file = None
# self.app_js = None
#
# @run_time
# def get_x_bogus(self, query: dict, user_agent: str, platform="PC"):
# if platform == "PC":
# return self.pc_js.call("sign", urlencode(query), user_agent)
# elif platform == "APP":
# return ""
# raise ValueError
#
# def close(self):
# self.pc_file.close()


class MsToken:
Expand Down Expand Up @@ -339,9 +338,9 @@ def get_web_id(ua: str) -> str | None:
"webid": "7255592572578842152",
"msToken": "Ui3F4s1tPEtozwxKgcizcCr1cx0oCVmx5NhSQqcYhiBDKnQ6O5f_PIwfhkKBw9dY6kDe8ncUSMhmkVV7ANocOdoGk2cPgiC4wWiyeVlTfyMDzFb2Kvxg3A2C2Xc1J1-H"
}
example = XBogus("../static/js/X-Bogus.js")
print("X-Bogus", example.get_x_bogus(params, HEADERS["User-Agent"]))
example.close()
# example = XBogus("../static/js/X-Bogus.js")
# print("X-Bogus", example.get_x_bogus(params, HEADERS["User-Agent"]))
# example.close()
print(MsToken.get_ms_token())
print(TtWid.get_tt_wid())
print("webid", WebID.get_web_id(HEADERS["User-Agent"]))
Expand Down

0 comments on commit 422fc1b

Please sign in to comment.