验证码的解决方案是通过资源工作者进行的——https://anti-captcha.com
要解决验证码,您需要先在资源上注册并充值余额。
文档 – https://anti-captcha.com/apidoc

安装

dart pub add dart_anticaptcha

或者

dependencies:
  dart_anticaptcha: ^1.1.4

用法

imageToText

使用此库最简单的方法是使用memoryImageToBase64()函数。此函数用于将图像转换为base64,然后将其上传到资源以解决验证码。
此外,要从网站获取base64图像,您需要使用networkImageToBase64()函数。

import 'package:dart_anticaptcha/dart_anticaptcha.dart';

void main() async {
  String key = 'YOUR_TOKEN';
  String memoryImage = 'captcha.jpeg';
  String networkImage = 'https://api.vk.com/captcha.php?sid=1';

  AntiCaptcha anticaptcha = AntiCaptcha(key);

  String? imgbase64 = await anticaptcha
      .networkImageToBase64(networkImage); //memoryImage or networkImage

  Map headers = {
    "clientKey": key,
    "task": {"type": "ImageToTextTask", "body": imgbase64}
  };
  dynamic result = await anticaptcha.imageToText(headers);
  print(result['solution']['text']);
}

recaptchaV2TaskProxyless

recaptchaV2Demo – 登陆页面地址。它可以位于网站上的任何位置,包括封闭的订阅者部分。我们的员工不会访问网站,而是模拟访问页面。

websiteKey – Recaptcha 密钥。更多详情 – https://anti-captcha.com/apidoc/articles/how-to-find-the-sitekey

import 'package:dart_anticaptcha/dart_anticaptcha.dart';

void main() async {
  String recaptchaV2Demo = 'https://patrickhlauke.github.io/recaptcha/';
  String websiteKey = 'YOUR_WEBSITE_KEY';
  String key = 'YOUR_TOKEN';

  AntiCaptcha antiCaptcha = AntiCaptcha(key);
  Map header = {
    "clientKey": key,
    "task": {
      "type": "RecaptchaV2TaskProxyless",
      "websiteURL": recaptchaV2Demo,
      "websiteKey": websiteKey
    }
  };
  Map response = await antiCaptcha.recaptchaV2TaskProxyless(header);
  print(response['solution']['gRecaptchaResponse']);
}

GitHub

查看 Github