这里说一下,上次我发表了,如何用芝麻ip搭建代理池,可以看这里,后面免费的套餐用完了(并不是我用量大 :有时常限制),这个教程可以对 ip需求不高的人做一个参考,因为芝麻代理每天的ip够我做项目用的了,没必要付钱,坏处就是这个免费的ip每天都需要进来领取且当天失效,但是好处就是 领取后 原服务正常使用
对比观察下登录接口的响应体
显然是一致的,说明登录接口获取得到的 ret_data就是PHPSESSID的值
于是找到登录接口,post请求、url
继续! 伪造请求头
表单:
登录接口:
# 登录
url = "https://wapi.http.linkudp.com/index/users/login_do"
body = {
'phone': '手机号',
'password': '密码',
'remember': '0'
}
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": 'gzip, deflate, br',
"Accept-Language": 'zh-CN,zh;q=0.9',
'Connection': 'keep-alive',
'Content-Length': '48',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Host': 'wapi.http.linkudp.com',
"Origin": 'https://www.zmhttp.com',
"Referer": 'https://www.zmhttp.com/',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'cross-site',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
}
response = requests.post(url, json=body, headers=headers)
print(response.text)
result=response.json()
print(result['ret_data'])
获取用户信息:
# 获取用户信息
url="https://wapi.http.linkudp.com/index/users/user_info"
body = {
}
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": 'gzip, deflate, br',
"Accept-Language": 'zh-CN,zh;q=0.9',
'Connection': 'keep-alive',
'Content-Length': '0',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Host': 'wapi.http.linkudp.com',
"Origin": 'https://www.zmhttp.com',
"Referer": 'https://www.zmhttp.com/ucenter/?first_time=0',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'cross-site',
'session-id': result['ret_data'],
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
}
response = requests.post(url, json=body, headers=headers)
print(response.text)
今天就先到这里,后面更新,因为今天已经领取过了,不想熬夜,收藏+关注哦!
好啦!完整代码在这里:
import requests
# 登录
url = "https://wapi.http.linkudp.com/index/users/login_do"
body = {
'phone': '手机号',
'password': '密码',
'remember': '0'
}
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": 'gzip, deflate, br',
"Accept-Language": 'zh-CN,zh;q=0.9',
'Connection': 'keep-alive',
'Content-Length': '48',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Host': 'wapi.http.linkudp.com',
"Origin": 'https://www.zmhttp.com',
"Referer": 'https://www.zmhttp.com/',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'cross-site',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
}
response = requests.post(url, json=body, headers=headers)
print(response.text)
result=response.json()
print(result['ret_data'])
# 获取用户信息
url="https://wapi.http.linkudp.com/index/users/user_info"
body = {
}
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": 'gzip, deflate, br',
"Accept-Language": 'zh-CN,zh;q=0.9',
'Connection': 'keep-alive',
'Content-Length': '0',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Host': 'wapi.http.linkudp.com',
"Origin": 'https://www.zmhttp.com',
"Referer": 'https://www.zmhttp.com/ucenter/?first_time=0',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'cross-site',
'session-id': result['ret_data'],
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
}
response = requests.post(url, json=body, headers=headers)
print(response.text)
#自动领取每日免费ip
url = "https://wapi.http.linkudp.com/index/users/get_day_free_pack"
body = {
'geetest_challenge': '',
'geetest_validate': '',
'geetest_seccode': ''
}
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": 'gzip, deflate, br',
"Accept-Language": 'zh-CN,zh;q=0.9',
'Connection': 'keep-alive',
'Content-Length': '53',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'Host': 'wapi.http.linkudp.com',
"Origin": 'https://www.zmhttp.com',
"Referer": 'https://www.zmhttp.com/ucenter/?first_time=0',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'cross-site',
'session-id': result['ret_data'],
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
}
response = requests.post(url, json=body, headers=headers)
print(response.text)