这个是python实现的。我只实现了获取sid和token。
[Python] 纯文本查看 复制代码 import hashlib
import requests
import urllib3
import re
urllib3.disable_warnings()
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/115.0.0.0 Safari/537.36"
}
def md5(str):
md = hashlib.md5(str.encode()) # 创建md5对象
return md.hexdigest() # md5加密
# 登录
def login():
data = {
"email": "你的账号",
"password": md5("你的密码"),
}
headers["x-requested-with"] = "XMLHttpRequest"
session = requests.session()
resp = session.post(
url="https://www.hifini.com/user-login.htm",
headers=headers,
data=data,
verify=False,
)
cookie_dic = requests.utils.dict_from_cookiejar(resp.cookies)
cookies = {
"bbs_sid": cookie_dic["bbs_sid"],
"bbs_token": cookie_dic["bbs_token"],
}
resp = session.get(
url="https://www.hifini.com/sg_sign.htm",
cookies=cookies,
verify=False,
)
result = re.findall('var sign = "(.*?)"', resp.text)
string = f"sign={result[0]}"
new_headers = {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
"X-Requested-With": "XMLHttpRequest",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36",
"Referer": "https://www.hifini.com/sg_sign.htm",
}
resp = requests.post(
url="https://www.hifini.com/sg_sign.htm",
data=string,
headers=new_headers,
cookies=cookies,
verify=False,
)
print(resp.text)
login() |