破解滑块验证码的思路主要有2种:
本次就使用第2种,第一种比较简单。废话不多说,直接上代码:
以下均利用无头浏览器进行获取
获得滑块验证的小图片
def get_image1(self,driver): """ 获取滑块验证缺口小图片 :param driver:chrome对象 :return:缺口小图片 """ canvas = driver.find_element_by_xpath("//div[@id='xy_img']").get_attribute("style") image_data=re.findall("data:image/jpg;base64,(.*?)\"\)",canvas)[0] # print(image_data) binary_image_data=base64.b64decode(image_data,'-_') file_like=BytesIO(binary_image_data) image=Image.open(file_like) return image