[python] Crawler notes (6) verification code recognition

Anti-climb mechanism

Verification code. Identify the data in the image of the verification code to simulate the login operation.

Operation to identify the verification code:

  • Artificial eye recognition. (Not recommended)
  • Third-party automatic identification
    • Cloud coding (hanging up)
    • Connect to the online identification picture network
    • Illustrated Network
    • Super Eagle

script

import base64
import json
import requests

def base64_api(uname, pwd,  img):
    with open(img, 'rb') as f:
        base64_data = base64.b64encode(f.read())
        b64 = base64_data.decode()
    data = {
    
    "username": uname, "password": pwd, "image": b64}
    result = json.loads(requests.post("http://api.ttshitu.com/base64", json=data).text)
    if result['success']:
        return result["data"]["result"]
    else:
        return result["message"]
    return ""


if __name__ == "__main__":
    img_path = "C:/Users/Administrator/Desktop/file.jpg"
    result = base64_api(uname='你的账号', pwd='你的密码', img=img_path)
    print(result)

Report an error

import json
import requests

def reportError(id):
    data = {
    
    "id": id}
    result = json.loads(requests.post("http://api.ttshitu.com/reporterror.json", json=data).text)
    if result['success']:
        return "报错成功"
    else:
        return result["message"]
    return ""

if __name__ == "__main__":
    result = reportError(id='成功返回的id')
    print(result)

Guess you like

Origin blog.csdn.net/Sgmple/article/details/112094806