Skip to content

Commit

Permalink
🧛‍♂️修复ttwid获取
Browse files Browse the repository at this point in the history
  • Loading branch information
Johnserf-Seed committed Aug 3, 2023
1 parent 9f114e6 commit 0870a82
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Util/algorithm/Server.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,33 @@ def getxttparams(self, url_path):
print(tips)
return jsonify(tips)

def gen_ttwid(self) -> str:
"""生成请求必带的ttwid
param :None
return:ttwid
"""
url = 'https://ttwid.bytedance.com/ttwid/union/register/'
data = '{"region":"cn","aid":1768,"needFid":false,"service":"www.ixigua.com","migrate_info":{"ticket":"","source":"node"},"cbUrlProtocol":"https","union":true}'
response = requests.request("POST", url, data=data)
# j = ttwid k = 1%7CfPx9ZM.....
for j, k in response.cookies.items():
tips = {
"status_code": "200",
"time": {
"strftime": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()),
"timestamp": int(round(time.time() * 1000))
},
"result": [{
"headers": {
"user-agent": self.ua,
"cookie": "ttwid=%s;" % k
}
}]
}
print(tips)
return jsonify(tips)


if __name__ == "__main__":
server = Server()
# 首页
Expand Down Expand Up @@ -161,5 +188,10 @@ def xttppath():
else:
return server.getxttparams(path)

# ttwid
@server.app.route('/xg/ttwid', methods=['GET', 'POST'])
def ttwid():
return server.gen_ttwid()


server.app.run(host='0.0.0.0',port='8889')

0 comments on commit 0870a82

Please sign in to comment.