1. 工作原理
0x00 基本原理
0x01 IP代理获取
{
"code": 0,
"data": [
{
"ip": "122.241.31.86",
"port": 4231
},
...
],
"msg": "0",
"success": true
}0x02 访问轻应用Url
0x03 主函数实现

Last updated
{
"code": 0,
"data": [
{
"ip": "122.241.31.86",
"port": 4231
},
...
],
"msg": "0",
"success": true
}
Last updated
def check_zm():
IP_API = 'http://webapi.http.zhimacangku.com/getip?num=5&type=2&pro=&city=0&yys=0&port=1&pack=234772&ts=0&ys=0&cs=0&lb=4&sb=0&pb=4&mr=1®ions='
res = json.loads(requests.get(IP_API).text) # 处理返回信息为Json
code = res['code']
if code == 0: #状态码为0则输出IP,反之则输出错误信息
return 1, res['data']
return 0, res['msg']def Deal_IP():
flag, data = check_zm() # 检查返回值是否包含IP
IPS = []
if flag:
for ips in data: # 遍历返回数据进行处理
proxymeta = str(ips["ip"]) + ':' + str(ips["port"])
IP = {"http": proxymeta} # 拼接IP并添加到字典中
IPS.append(IP)
return IPS # 返回字典def Run(App_id, IP):
url = 'https://q.yiban.cn/app/index/appid/' + App_id
try:
res1 = requests.get(url, proxies=IP, headers={'UA': xxx)
return 1
except requests.exceptions.SSLError: # 易班接口出错
return 0def main():
flag, msg = check_zm() # 检验代理池连通性
if flag:
Appid = input('请输入轻应用ID:')
run_time = int(input('请输入运行次数:'))
if run_time <= 5:
run_time = 1
else:
run_time = int(run_time / 5)
cnt = 0
while run_time: # 执行任务
run_time -= 1
IPS = Deal_IP()
for ip in IPS:
cnt += 1
Run(Appid, ip)
print('\r当前请求%d次' % cnt, end='')
time.sleep(1)
print('\n任务完成!')
else:
print(msg) # 显示错误信息
print("芝麻代理官网:https://www.zmhttp.com/")
i = input('按回车重试')
main()