def get_position( datu):
i_j = []
img = Image.open(io.BytesIO(datu))
img = img.convert("RGBA") # 转换格式,确保像素包含alpha通道
width, height = img.size # 长度和宽度
for i in range(0, width): # 遍历所有长度的点
for j in range(0, height): # 遍历所有宽度的点
data = img.getpixel((i, j)) # 获取一个像素
if (data.count(255) == 4): # RGBA都是255,表示白色
i_j.append((i, j))
return i_j
def get_sectoken( 1):
for retry_num in range(3):
try:
time.sleep(0.1)
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.33',
}
yzm_url = 'https://gcxm.hunanjs.gov.cn/AjaxHandler/PersonHandler.ashx?method=GetVerifyImg'
yzm_res = requests.get(yzm_url, proxies=self.proxies, timeout=15, headers=headers)
vid = yzm_res.json()[2]
datu = base64.b64decode(yzm_res.json()[1])
move_x = int(get_position(datu)[0][0])
headers['Cookie'] = f'ASP.NET_SessionId={yzm_res.cookies.get("ASP.NET_SessionId")}'
for x in [-1, -2, -3, 0, -5, -2, -1, 0]:
time.sleep(0.1)
move_x_v2 = move_x + x
url = f'https://gcxm.hunanjs.gov.cn/AjaxHandler/PersonHandler.ashx?method=GetListPage&type=6&corptype_1=&corpname_1=&licensenum_1=&Province_1=430000&City_1=&county_1=&persontype=&persontype_2=&personname_2=&idcard_2=&certnum_2=&corpname_2=&prjname_3=&corpname_3=&prjtype_3=&cityname_3=&corpname_5=&corpcode_5=&legalman_5=&cityname_5=&SafeNum_6=&corpname_6=&corpname_7=&piciname_7=&corptype_7=&corpname_8=&corpcode_8=&legalman_8=&cityname_8=&pageSize=30&pageIndex={page}&moveX={move_x_v2}&verifyid={vid}'
res = requests.get(url, proxies=self.proxies, headers=headers, timeout=15)
if '图片验证失败' in res.text:
continue
return res.json().get('data')
except Exception as e:
logging.info(e)
开箱即用python破解滑块缺口验证码
最新推荐文章于 2025-09-09 09:25:15 发布
该代码实现了一个从网页获取验证码,处理图像以定位白色像素,然后进行移动并发送请求的过程。主要用于网页数据的抓取,涉及到图像处理、HTTP请求和Cookie管理。
540





