获取Token接口
API请求方式:http get/post
可配置参数:
admin:Dove网站账户名(必填)
pwd:Dove网站账户密码(必填)
请求连接:https://dvapi.doveproxy.net/cmapi.php?rq=login&user=admin&password=pwd
请求成功返回:
{
"errno": 200,
"msg": "Success",
"data": {
"token": "O12314141414155ZKckd2Vml0SVArUT09"
}
}
注意:token是长期有效的
errno返回值参考:
200:成功
800:账号被封禁
801:用户不存在
802:用户名或密码错误
803:用户名和密码不能为空
获取用户信息接口
API请求方式:http get/post
可配置参数:
admin:Dove网站账户名(必填)
kon:Dove账户token(必填)
请求连接:https://dvapi.doveproxy.net/cmapi.php?rq=getUserInfo&user=admin&token=kon
请求成功返回:
{
"errno": 200,
"msg": "Success",
"data": {
"username": "gaozy",
"points_now": "99599", // {} 用户当前金币
"sys_group_id": "VIP1", //用户等级
"cellphone": "13521192700",
"email": "[email protected]"
}
}
errno返回值参考:
200:成功
801:用户不存在
803:用户名和密码不能为空
获取IP接口
API请求方式:http get/post
可配置参数:
user:Dove网站账户名(必填)
token:Dove账户token(必填)
geo:国家geo代码(必填)【点击查看国家代码表】
city:城市编号 【点击查看城市代码表】
accurate:IP获取方式(必填)(默认配置为0,0为根据geo参数来获取;1为根据selfip参数的地理位置来获取相似ip)
selfip:填写参照ip(当accurate为0时可不填,当accurate为1时必填)
timeout:有效时间(可选,单位分钟,默认配置为10分钟,可在1-35之前进行配置)
auth:认证方式(默认为0,0为IP白名单认证,1为用户密码认证)
agreement:代理协议(默认配置为0,0为Socks5协议代理,1为HTTP协议代理)
repeat:24小时内可获取重复ip(默认配置为0,0为不获取重复ip,1为获取重复ip)
num:获取ip数量(可选,默认1,最多可一次性获取10个)
type_ip:协议类型(可选,不传为获取所有,1为获取IPv4 2为获取IPv6)
白名单认证方式请求连接:https://dvapi.doveproxy.net/cmapi.php?rq=distribute&user=admin&token=O12314141414155ZKckd2Vml0SVArUT09&auth=0&geo=BJ&city=426939&agreement=0&timeout=10&num=2&type_ip=1
白名单认证方式(请求单个IP)返回:
{
"errno": 200,
"msg": "Success",
"data": {
"geo": "mx", //{}国家
"ip": "47.253.12.97", //代理ip
"port": 40076, //代理端口
"d_ip": "201.162.169.86" //目标ip
"timeout": 600 //有效时间(秒)
}
}
白名单认证方式(请求多个IP)返回:
{
"errno": 200,
"msg": "Success",
"data": [{
"geo": "mx", //{}国家
"ip": "47.253.12.97", //代理ip
"port": 40076, //代理端口
"d_ip": "201.162.169.86" //目标ip
"timeout": 600 //有效时间(秒)
},{
"geo": "mx", //{}国家
"ip": "47.253.12.97", //代理ip
"port": 40076, //代理端口
"d_ip": "201.162.169.86" //目标ip
"timeout": 600 //有效时间(秒)
}]
}
用户名认证方式请求连接:https://dvapi.doveproxy.net/cmapi.php?rq=distribute&user=admin&token=O12314141414155ZKckd2Vml0SVArUT09&auth=1&geo=BJ&city=426939&agreement=0&timeout=10&num=2
用户名认证方式(请求单个IP)返回:
{
"errno": 200,
"msg": "Success",
"data": {
"geo": "mx", //{}国家
"ip": "47.253.12.97", //代理ip
"port": 40076, //代理端口
"d_ip": "201.162.169.86" //目标ip
"timeout": 600 //有效时间(秒)
"username": "zhansan" //用户名
"password": "1asfadqdax" //密码
}
}
用户名认证方式(请求多个IP)返回:
{
"errno": 200,
"msg": "Success",
"data": [{
"geo": "mx", //{}国家
"ip": "47.253.12.97", //代理ip
"port": 40076, //代理端口
"d_ip": "201.162.169.86" //目标ip
"timeout": 600 //有效时间(秒)
"username": "zhangsan" //用户名
"password": "1asfadqdax" //密码
},{
"geo": "mx", //{}国家
"ip": "47.253.12.97", //代理ip
"port": 40076, //代理端口
"d_ip": "201.162.169.86" //目标ip
"timeout": 600 //有效时间(秒)
"username": "zhansan" //用户名
"password": "2asfadqdax" //密码
}]
}
errno返回值参考:
200:成功
800:账号被封禁
801:用户不存在
802:用户名或密码错误
803:用户名和密码不能为空
902:传递的参数不正确
903:无效的国家代码
904:无效的类型
906:ip列表为空
403:积分不足
408:selfip不能为空
409:获取IP请求的频率太高,请稍后再试
500:IP token 已经创建,请从新获取
400:失败,系统异常
注意:IP白名单认证获取的代理IP由获取代理IP时的本地公网IP和白名单列表中的IP使用,使用命令行窗口查看公网IP:curl cip.cc
Curl
1.获取token
curl -d "user=abcd&password=abcd" https://dvapi.doveproxy.net/cmapi.php?rq=login
{"errno":200,"msg":"Success","data":{"token":"OXhRbHd2MHVvaWZKckd2Vml0SVArUT09"}}
2.获取代理ip
curl -ipv4 -d "user=abc&token=OXhRbHd2MHVvaWZKckd2Vml0SVArUT09&geo=mx" https://dvapi.doveproxy.net/cmapi.php?rq=distribute
{"errno":200,"msg":"Success","data":{"geo":"mx","ip":"47.253.12.97","port":40004,"d_ip":"189.203.105.247"}}
3.使用代理ip
curl -ipv4 --socks5 47.253.12.97:40004 https://www.google.com
Java
import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.HttpURLConnection; import java.net.InetSocketAddress; import java.net.MalformedURLException; import java.net.Proxy; import java.net.URL; public class Demo { public static void main(String[] args) { System.setProperty("java.net.preferIPv4Stack", "true");//设置jvm优先使用ipv4网络 String uname = "test"; String upass = "test"; //1 String token = login(uname, upass); //2 ProxyBean proxy = getProxyIp(uname, token); //3 usedProxyIp(proxy.proxy_ip,proxy.proxy_port); } //步骤1通过登录api获取token public static String login(String uname, String upass) { String params = "user=" + uname + "&password=" + upass; String reqUrl = "https://dvapi.doveproxy.net/cmapi.php?rq=login"; try { HttpURLConnection httpURLConnection = getUrlConnection(reqUrl); OutputStream out = httpURLConnection.getOutputStream(); out.write(params.getBytes()); out.flush(); out.close(); String msg = ""; int code = httpURLConnection.getResponseCode(); System.out.println("code:" + code); if (code == 200) { msg = getConnectionResult(httpURLConnection); System.out.println("msg:" + msg); //{"errno":200,"msg":"Success","data":{"token":"OXhRbHd2MHVvaWZKckd2Vml0SVArUT09"}} JSONObject jo = JSONObject.parseObject(msg); int errno = jo.getIntValue("errno"); jo = jo.getJSONObject("data"); String token = jo.getString("token"); System.out.println("errno:" + errno); System.out.println("token:" + token); return token; } } catch (IOException e) { e.printStackTrace(); } catch (JSONException e) { e.printStackTrace(); } return null; } //步骤2 通过api获取代理ip public static ProxyBean getProxyIp(String uname, String token) { String params = "geo=mx&user=" + uname + "&token=" + token; String reqUrl = "https://dvapi.doveproxy.net/cmapi.php?rq=distribute"; try { HttpURLConnection httpURLConnection = getUrlConnection(reqUrl); OutputStream out = httpURLConnection.getOutputStream(); out.write(params.getBytes()); out.flush(); out.close(); String msg = ""; int code = httpURLConnection.getResponseCode(); System.out.println("code:" + code); if (code == 200) { msg = getConnectionResult(httpURLConnection); } //{"errno":200,"msg":"Success","data":{"geo":"mx","ip":"47.253.12.97","port":40004,"d_ip":"189.203.105.247"}} System.out.println("msg:" + msg); JSONObject jo = JSONObject.parseObject(msg); int errno = jo.getIntValue("errno"); jo = jo.getJSONObject("data"); String geo = jo.getString("geo"); String ip = jo.getString("ip"); int port = jo.getInteger("port"); String d_ip = jo.getString("d_ip"); System.out.println("errno:" + errno); System.out.println("geo:" + geo); System.out.println("ip:" + ip); System.out.println("port:" + port); System.out.println("d_ip:" + d_ip); ProxyBean proxy = new ProxyBean(); proxy.proxy_ip = ip; proxy.proxy_port = port; return proxy; } catch (IOException e) { e.printStackTrace(); }catch (JSONException e) { e.printStackTrace(); } return null; } //步骤3使用代理ip public static void usedProxyIp(String proxyIp, int proxyPort) { try { InetSocketAddress inetSocketAddress = new InetSocketAddress(proxyIp, proxyPort); Proxy proxy = new Proxy(Proxy.Type.SOCKS, inetSocketAddress); URL url = new URL("https://www.google.com"); HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(proxy); httpURLConnection.setRequestMethod("GET"); httpURLConnection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); httpURLConnection.setConnectTimeout(3000); httpURLConnection.setDoOutput(true); httpURLConnection.setDoInput(true); httpURLConnection.connect(); int code = httpURLConnection.getResponseCode(); System.out.println("code:" + code); if (code == 200) { String content = getConnectionResult(httpURLConnection); System.out.println("content:" + content); } } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } public static class ProxyBean{ public String proxy_ip; public int proxy_port; } public static String getConnectionResult(HttpURLConnection httpURLConnection) throws IOException { InputStream inStream = httpURLConnection.getInputStream(); ByteArrayOutputStream outStream = new ByteArrayOutputStream(); byte[] buffer = new byte[512]; int length = -1; String msg; while ((length = inStream.read(buffer)) != -1) { outStream.write(buffer, 0, length); } outStream.close(); inStream.close(); msg = outStream.toString(); return msg; } public static HttpURLConnection getUrlConnection(String reqUrl) throws IOException { URL url = new URL(reqUrl); HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection(); httpURLConnection.setRequestMethod("POST"); httpURLConnection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"); httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); httpURLConnection.setConnectTimeout(3000); httpURLConnection.setDoOutput(true); httpURLConnection.setDoInput(true); httpURLConnection.connect(); return httpURLConnection; } }
Php
//注意,php使用curl请求 所以php需要安装curl扩展 function curl($uri) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $uri); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 1); curl_setopt($curl, CURLOPT_TIMEOUT, 3); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); $response = curl_exec($curl); curl_close($curl); return $response; } //1.获取token $login = curl("https://dvapi.doveproxy.net/cmapi.php?rq=login&user=abc&password=123456"); //{"errno":200,"msg":"Success","data":{"token":"OXhRbHd2MHVvaWZKckd2Vml0SVArUT09"}} //2.获取代理ip $login = json_decode($login,true); $login = $login['data']; $proxy = curl("https://dvapi.doveproxy.net/cmapi.php?rq=distribute&user=abc&token=".$login['token']."&geo=mx"); //{"errno":200,"msg":"Success","data":{"geo":"mx","ip":"47.253.12.97","port":40004,"d_ip":"189.203.105.247"}} //3.使用代理ip $proxy = json_decode($proxy,true); $proxy = $proxy['data']; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, "https://www.google.com"); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 60); curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_PROXY, $proxy['ip']); //代理ip curl_setopt($ch, CURLOPT_PROXYPORT, $proxy['port']); // 代理端口 curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); $curlScrapedPage = curl_exec($ch); curl_close($ch); echo $curlScrapedPage;