【Python】记录抓包分析自动领取芝麻HTTP每日免费IP(成品+教程)

背景:

这里说一下,上次我发表了,如何用芝麻ip搭建代理池,可以看这里,后面免费的套餐用完了(并不是我用量大 :有时常限制),这个教程可以对 ip需求不高的人做一个参考,因为芝麻代理每天的ip够我做项目用的了,没必要付钱,坏处就是这个免费的ip每天都需要进来领取且当天失效,但是好处就是 领取后 原服务正常使用
【Python】记录抓包分析自动领取芝麻HTTP每日免费IP(成品+教程)_第1张图片


抓包:

F12,通过观察发现都是通过cookie来进行验证的,
【Python】记录抓包分析自动领取芝麻HTTP每日免费IP(成品+教程)_第2张图片

对比观察下登录接口的响应体
【Python】记录抓包分析自动领取芝麻HTTP每日免费IP(成品+教程)_第3张图片
显然是一致的,说明登录接口获取得到的 ret_data就是PHPSESSID的值
【Python】记录抓包分析自动领取芝麻HTTP每日免费IP(成品+教程)_第4张图片

于是找到登录接口,post请求、url
【Python】记录抓包分析自动领取芝麻HTTP每日免费IP(成品+教程)_第5张图片
继续! 伪造请求头
【Python】记录抓包分析自动领取芝麻HTTP每日免费IP(成品+教程)_第6张图片
表单:
【Python】记录抓包分析自动领取芝麻HTTP每日免费IP(成品+教程)_第7张图片


python代码:

登录接口:

# 登录
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)

成功图:
登录后返回值
【Python】记录抓包分析自动领取芝麻HTTP每日免费IP(成品+教程)_第8张图片
返回用户信息值
【Python】记录抓包分析自动领取芝麻HTTP每日免费IP(成品+教程)_第9张图片

原图:
【Python】记录抓包分析自动领取芝麻HTTP每日免费IP(成品+教程)_第10张图片


最后:

今天就先到这里,后面更新,因为今天已经领取过了,不想熬夜,收藏+关注哦!
【Python】记录抓包分析自动领取芝麻HTTP每日免费IP(成品+教程)_第11张图片

好啦!完整代码在这里:

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)



你可能感兴趣的:(python,笔记,http,python,tcp/ip,抓包,爬虫)