Code Monkey home page Code Monkey logo

biliticker_gt's Introduction

BiliTicker-gt-python

极验验证模块的python语言绑定

使用方式

  1. pip install bili_ticket_gt_python
  2. import bili_ticket_gt_python
  3. slide = bili_ticket_gt_python.SlidePy()
  4. click = bili_ticket_gt_python.ClickPy()
  5. 通过slide和click调用相关函数

绑定的函数见py.rs文件

demo

执行测试

import bili_ticket_gt_python
slide = bili_ticket_gt_python.SlidePy()
click = bili_ticket_gt_python.ClickPy()

try:
    #改为注册滑块challenge和gt的url
    validate = slide.test("http://127.0.0.1:5000/pc-geetest/register")
    print(validate)
except Exception as e:
    print("识别失败")
    print(e)

try:
    #改为注册点选challenge和gt的url
    validate = click.test("https://passport.bilibili.com/x/passport-login/captcha?source=main_web")
    print(validate)
except Exception as e:
    print("识别失败")
    print(e)

通过gt和challenge调用 仅支持点选验证码

import bili_ticket_gt_python
click = bili_ticket_gt_python.ClickPy()
try:
    (gt, challenge) = click.register_test("https://passport.bilibili.com/x/passport-login/captcha?source=main_web")
    validate = click.simple_match(gt, challenge)
    print(validate)
except Exception as e:
    print("识别失败")
    print(e)

通过gt和challenge调用(自动重试) 仅支持点选验证码

import bili_ticket_gt_python
click = bili_ticket_gt_python.ClickPy()

try:
    (gt, challenge) = click.register_test("https://passport.bilibili.com/x/passport-login/captcha?source=main_web")
    validate = click.simple_match_retry(gt, challenge)
    print(validate)
except Exception as e:
    #验证码失效有两种可能性
    # 1. 验证码生成过后过了太久,时间导致的失效
    # 2. 验证码重试次数过多,需要unset,unset接口请自己扒下来封装吧,我真的懒得封装了
    print("自动重试仍然有极小概率报错(超时时间即为验证码失效时间)")
    print(e)
#不要100%依赖于demo!!!动动脑子

分步调用

import bili_ticket_gt_python
slide = bili_ticket_gt_python.SlidePy()

try:
    (gt, challenge) = slide.register_test("http://127.0.0.1:5000/pc-geetest/register")
    (_, _) = slide.get_c_s(gt, challenge)
    _type = slide.get_type(gt, challenge)
    if _type != "slide":
        raise Exception("验证码类型错误")
    (c, s, args) = slide.get_new_c_s_args(gt, challenge)
    #注意滑块验证码这里要刷新challenge
    challenge = args[0]
    key = slide.calculate_key(args)
    #rt固定即可
    #此函数是使用项目目录下的slide.exe生成w参数,如果文件不存在会报错,你也可以自己接入生成w的逻辑函数
    w = slide.generate_w(key, gt, challenge, str(c), s, "abcdefghijklmnop")
    (msg, validate) = slide.verify(gt, challenge, w)
    print(validate)
except Exception as e:
    print("识别失败")
    print(e)
import bili_ticket_gt_python
import time
click = bili_ticket_gt_python.ClickPy()

try:
    (gt, challenge) = click.register_test("https://passport.bilibili.com/x/passport-login/captcha?source=main_web")
    (_, _) = click.get_c_s(gt, challenge)
    _type = click.get_type(gt, challenge)
    if _type != "click":
        raise Exception("验证码类型错误")
    (c, s, args) = click.get_new_c_s_args(gt, challenge)
    before_calculate_key = time.time()
    key = click.calculate_key(args)
    #rt固定即可
    #此函数是使用项目目录下的click.exe生成w参数,如果文件不存在会报错,你也可以自己接入生成w的逻辑函数
    w = click.generate_w(key, gt, challenge, str(c), s, "abcdefghijklmnop")
    #点选验证码生成w后需要等待2秒提交
    w_use_time = time.time() - before_calculate_key
    print("w生成时间:", w_use_time)
    if w_use_time < 2:
        time.sleep(2 - w_use_time)
    (msg, validate) = click.verify(gt, challenge, w)
    print(validate)
except Exception as e:
    print("识别失败")
    print(e)

biliticker_gt's People

Contributors

amorter avatar ziantt avatar woshiluo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.