小小博客

  • 首页
  • 关于博客
  • 个人日志
  • VPS代理
小小博客
WIKI Tool For MMN6.COM
  1. 首页
  2. 个人日志
  3. 正文

c# 原生2captcha图片打码实现

2024年2月1日 847点热度 0人点赞 0条评论

封装函数

public static async Task captcha2(string VImage, int checkt = 0)
{
var secretKey = "b8*************"; //KEY
var url = "https://2captcha.com/in.php?key=" + secretKey;
var res = "";
using (HttpClient client = new HttpClient())
{
var content = new MultipartFormDataContent("Upload----" + DateTime.Now.ToString(CultureInfo.InvariantCulture));

content.Add(new StringContent(VImage), "body"); //BASE64图片,不包括data:image/png;base64,
content.Add(new StringContent("base64"), "method"); //BASE64图片
content.Add(new StringContent("en"), "lang"); //英文打码
content.Add(new StringContent("10"), "max_len"); //最大长度
content.Add(new StringContent("Choose a correct word or calculation"), "textinstructions"); //备注给打码人员看
content.Add(new StringContent("4497"), "soft_id"); //开发者ID 更多参数见 https://2captcha.com/2captcha-api

var response = await client.PostAsync(url, content);
var stringResponse = await response.Content.ReadAsStringAsync();
stringResponse = stringResponse.ToString();
if (stringResponse.Contains("OK|"))
{
var resid = stringResponse.Replace("OK|", "").Trim();

url = "https://2captcha.com/res.php?key=" + secretKey + "&action=get&id=" + resid;

//获取结果
for (int k = 0; k < 10; k++)
{
string jsonStr = Main.GetHtml(url);//url
if (jsonStr.Contains("ERROR_"))
{ //验证码识别失败
res = "ERROR";
break;
}else if (jsonStr.Contains("OK|"))
{ //正确返回
res = jsonStr.Replace("OK|", "").Trim();
break;
}
else if (jsonStr.Contains("CAPCHA_NOT_READY"))
{ //正在识别中......
Delay(6000);
}
}

if(res == "")
{
res = "ERROR";
}
}
else
{
res = "ERROR";
}

}

Console.WriteLine(res);

return res;
}

2captcha打码注册平台注册 =》 查看

标签: 暂无
最后更新:2025年6月4日

MMN6

格局

点赞
< 上一篇
下一篇 >

文章评论

razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
取消回复
分类目录
  • Windows
  • Liunx
  • VPS代理
  • 个人日志
  • 海外电商
  • 社会百态
标签聚合
ubuntu c# AI Deepfacelab vs2022 Android SecureCRT Firefox
最新 热点 随机
最新 热点 随机
Shell命令处理大数据分割 Notepad++ 替换空格乱码 3proxy 代理使用 Android Pixel 刷机+root Visual Studio VS2022 激活密钥 WIN10系统点不开开始菜单和右下角日期解决办法
Notepad++ 替换空格乱码Shell命令处理大数据分割
centos 7 apache 安装SSL 服务器推荐 SecureCRT 8 注册码 个人博客站点备份SHELL脚本 MYSQL大数据快速导出 Mysql 快速删除大表记录的操作方法

COPYRIGHT © 2005 - 2025 小小博客. ALL RIGHTS RESERVED.