调用打码平台api获取验证码 (C#版)
一、打码平台很多,这里选择两个:联众和斐斐
联众开发文档:
https://www.jsdati.com/docs/guide
斐斐开发文档:
http://docs.fateadm.com/web/#/1?page_id=1
二、联众打码
从文档可以看到联众的接口是 https://v2-api.jsdama.com/upload
大多数验证码类型是四位数字字母,从这里可以看到我们需要的类型是1001.查看类型地址:https://www.jsdati.com/docs/price
获取需要的参数并发送post请求即可:
public class LianzhongRun
{
private const string ApiCode = "https://v2-api.jsdama.com/upload";
public static string LianZhongCode(string imgUrl)
{
var img64 = NetHandle.GetImageAsBase64Url(imgUrl).Result;
LianZhongRequestModel param = new LianZhongRequestModel();
param.captchaData = img64;
param.softwareId = ;
param.softwareSecret = "";
param.username = "";
param.password = "";
// captchaType 类型,查看:https://www.jsdati.com/docs/price
param.captchaType = ;
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Add("host", "v2-api.jsdama.com");
_client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36");
StringContent content = new StringContent(JsonConvert.SerializeObject(param), Encoding.UTF8,
"application/json");
HttpResponseMessage response = _client.PostAsync(ApiCode, content).Result;
string result = response.Content.ReadAsStringAsync().Result;
Console.WriteLine("返回结果--" + result);
if (!result.Contains("recognition")) return string.Empty;
dynamic resultObj = JsonConvert.DeserializeObject(result);
var data = resultObj["data"];
string recognition = data["recognition"];
Console.WriteLine("验证码:" + recognition);
return recognition.Trim();
}
}
}
三、斐斐打码
同样的方式,斐斐接口的请求代码如下
public class FeifeiRun
{
private static string ApiCode = "http://pred.fateadm.com/api/capreg";
private static string PdId = "";
private static string PdKey = "";
private static string AppKey = "";
private static string AppId = ""; /// <summary>
/// 斐斐打码
/// </summary>
/// <param name="imgUrl"></param>
/// <returns></returns>
public static string FeifeiCode(string imgUrl)
{
var img64 = NetHandle.GetImageAsBase64Url(imgUrl).Result;
var timestamp = TimeHelper.GetCurrentTimeUnix();
string cur_tm = TimeHelper.GetCurrentTimeUnix();
string sign = SecurityHelper.CalcSign(PdId, PdKey, cur_tm);
string asign = SecurityHelper.CalcSign(AppId, AppKey, cur_tm);
var predict_type = "";
var imgBytes = NetHandle.ReadBytes(imgUrl);
var values = new Dictionary<string, string>
{
{ "user_id",PdId},
{ "timestamp",timestamp},
{ "sign",sign},
{ "app_id",AppId},
{ "asign",asign},
{ "predict_type",predict_type},
{ "img_data",img64}
}; using (var _client = new HttpClient())
{
var content = new FormUrlEncodedContent(values);
HttpResponseMessage response = _client.PostAsync(ApiCode, content).Result;
string result = response.Content.ReadAsStringAsync().Result;
var data = JsonConvert.DeserializeObject<HttpRspData>(result);
if (!string.IsNullOrEmpty(data.RspData))
{
// 附带附加信息
HttpExtraInfo einfo = JsonConvert.DeserializeObject<HttpExtraInfo>(data.RspData);
data.einfo = einfo;
}
var resultCode = data.einfo.result.Trim();
Console.WriteLine("code:" + resultCode);
return resultCode;
}
}
}
五、完整代码
https://github.com/DavideYang125/VerificationCodeObtainDemo
调用打码平台api获取验证码 (C#版)的更多相关文章
- asp.net 模拟CURL调用微信公共平台API 上传下载多媒体文
近公司项目上在开发微信服务号的接口,需要给用户回复图片或语音或视频,这个时候就需要用到 上传下载多媒体文件接口,微信在这方面推荐采用的是开源函数库curl实现的,CURL项目包括很多版本,我主要测试的 ...
- 微信小程序wx.getLocation()获取经纬度及JavaScript SDK调用腾讯地图API获取某一类地址
简介 腾讯位置服务为微信小程序提供了基础的标点能力.线和圆的绘制接口等地图组件和位置展示.地图选点等地图API位置服务能力支持,使得开发者可以自由地实现自己的微信小程序产品. 在此基础上,腾讯位置服务 ...
- asp.net 模拟CURL调用微信公共平台API 上传下载多媒体文件接口
FormItem类 public class FormItem { public string Name { get; set; } public ParamType ParamType { get; ...
- Python3对接华三CAS平台Api获取虚拟机监控信息-渐入佳境
--时间:2021年2月3日 --作者:飞翔的小胖猪 说明 使用python对接华三CAS虚拟化平台,通过厂商提供的api接口获取每个集群下所有虚拟机的监控信息,并保存数据在本地的mariadb数据库 ...
- Python 通过打码平台实现验证码
在爬虫时,经常遇到登录需要验证码的情况,简单的验证码可以自己解决,复制的验证码需要借助机器学习,有一定的难度.还有一个简单的方案就是采用付费的打码平台. 比如R若快(http://www.ruokua ...
- 在C#中调用API获取网络信息和流量
原文 在C#中调用API获取网络信息和流量 最近一项目中要求显示网络流量,而且必须使用C#. 事实上,调用 IpHlpApi.dll 的 GetIfTable API 可以轻易获得网络信息和网络流量. ...
- 【转】百度API获取城市名地名(附源码)
在做一个软件时,用到了定位功能.网上有很多关于google 的GPS定位,但网上关于google定位都没有用, 搜索下原因:(这里建议大家在中国就尽量不使用系统自带的定位) 因为Google的服务器不 ...
- 百度AI开放平台- API实战调用
百度AI开放平台- API实战调用 一. 前言 首先说一下项目需求. 两个用户,分别上传了两段不同的文字,要计算两段文字相似度有多少,匹配数据库中的符合条件的数据,初步估计列出来会有60-1 ...
- 如何使用Postman快速简单的调用快递物流平台快递鸟API接口
前沿 快递鸟是一家聚合类的第三方快递物流平台,目前该平台提供的产品主要以API为主.由于API不能直观的看到产品效果,需要进行API对接联调成功后才能真实的看到产品的实际效果.但是如果一上来就写代码进 ...
随机推荐
- 如何丧心病狂的使用python爬虫读小说
写在前边 其实一直想入门python很久了,慕课网啊,菜鸟教程啊python的基础的知识被我翻了很多遍了,但是一直没有什么实践.刚好,这两天被别人一直安利一本小说<我可能修的是假仙>,还在 ...
- hTTP的URL编码
使用jdk提供的类完成URL的编解码 public class UrlDemo { public static void main(String[] args) throws Exception { ...
- C++ STL partial_sort_copy greater
#include <iostream>#include <deque>#include <algorithm>#include <vector>#inc ...
- centos下使用virtualenv建立python虚拟环境
在centos使用python3的virtualenv,先用yum install python3 安装后pip3也已经安装好了,pip3 install virtualenv, 在系统中新建一个空文 ...
- VLC播放器web插件接口(Part1)
本文转自:http://blog.csdn.net/xiaoxiaoxuewen/article/details/7698803Embed tag attributesTo embed the plu ...
- PyToune:一款类Keras的PyTorch框架
PyToune is a Keras-like framework for PyTorch and handles much of the boilerplating code needed to t ...
- JKD1.8新特性
1.Optional类 Optional是jdk1.8引入的类型,Optional是一个容器对象,它包括了我们需要的对象,使用isPresent方法判断所包 含对象是否为空,isPresent方法返回 ...
- 解决mosh: Nothing received from server on UDP port 60001 环境: centos7.1
主要问题在于有的教程使用iptables命令来开启对应端口, 但是centos7.1中虽然iptables仍然存在, 但是没有默认安装相关服务, 而是使用firewalld来管理防火墙. 所以我开始以 ...
- AssassinGo: 基于Go的高并发可拓展式Web渗透框架
转载自FreeBuf.COM AssassinGo是一款使用Golang开发,集成了信息收集.基础攻击探测.Google-Hacking域名搜索和PoC批量检测等功能的Web渗透框架,并且有着基于Vu ...
- Java学习笔记-包装类
基本数据类型对象包装类的最常见作用,就是用于基本数据类型和字符串类型之间做转换 包装类的由来 为了解决8种基本数据类型的变量不能当成Object类型变量使用的问题,Java提供了包装类(Wrapper ...