验证码破解全家桶(滑动验证码、数字验证码、极验验证码)

一、滑动验证码:(以企查查为例)

from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
#滑块验证
def validation():
    button_status = is_element_exist('nc_1_n1z')  # 按钮状态
    if button_status:
        button = WebDriverWait(driver, timeout=10, poll_frequency=0.5).until(
            lambda x: x.find_element_by_id('nc_1_n1z'),
            message='按钮定位超时')
    else:  # 滑动失效
        button = WebDriverWait(driver, timeout=10, poll_frequency=0.5).until(
            lambda x: x.find_element_by_id('nc_2_n1z'),
            message='按钮定位超时')
    # 滑动滑块
    ActionChains(driver).click_and_hold(button).perform()
    ActionChains(driver).move_by_offset(xoffset=263, yoffset=0).perform()  #263是滑动距离坐标,可从源码算出
    ActionChains(driver).release().perform()
    time.sleep(1)

二、数字字母验证码(以知乎为例)

posted @ 2020-11-24 11:25  Eliphaz  阅读(657)  评论(0编辑  收藏  举报