Autojs怎么实现类似python session的效果?
我想用autojs写个网站的签到脚本,我用登录获取了bbs_sid和bbs_token,在签到页面使用get签到显示未登陆。
var url="https://www.hifini.com/sg_sign.htm";
var resp = http.get(url,cookies);
log(resp.body.string()); 这个是python实现的。我只实现了获取sid和token。
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}"
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() 你的sign值呢 雾霭c 发表于 2024-4-8 18:02
你的sign值呢
要登录才有,卡在这里了。
本帖最后由 Bayonet 于 2024-4-26 11:02 编辑
懒得折腾了,手机下了个Pydroid3。用autojs6打开py解决。
//吾爱破解 Prepared By:Bayonet 禁止转载
function HifiniSingin()
{
app.viewFile("/sdcard/python/hifini.py");
className("android.widget.TextView").text("hifini.py").waitFor();
sleep(1000);
var clickstart=id("fab").findOne(5000);
if(clickstart!=null)
{
click(clickstart.bounds().centerX(),clickstart.bounds().centerY());
id("content").waitFor();
sleep(5000);
log("Hifini签到完成");
}
} 自己已解决。
页:
[1]