住宅IP
动态机房IP
HTTP/HTTPS
SOCKS5
请求切换
到期时间切换
TXT
JSON
HTML
回车换行(\r\n)
回车(\r)
换行(\n)
Tab(\t)
自定义字符
名称 | 类型 | 必选 | 说明 |
---|---|---|---|
num | int | 是 | 提取ip数量 |
country | string | 否 | 国家 查看国家代码 |
protocol | string | 否 | 协议(http:HTTP/HTTPS socks5:SOCKS5) |
format | string | 否 | 数据格式:TXT:1 JSON:2 HTML:3 |
sep | int | 否 | 分隔符(1:\r\n 2:/br 3:\r 4:\n 5:\t 6 :自定义分隔符) |
csep | string | 否 | 自定义分隔符 |
{ "code": 0, "success": true, "msg": "0", "data": [ {"ip": "47.244.192.12", "port": 16098}, {"ip": "47.244.192.12", "port": 15698} ] }
名称 | 类型 | 说明 |
---|---|---|
IP | string | IP地址 |
POST | int | 端口号 |
生成API链接,调用HTTP GET请求即可返回所需的IP结果 ,可以直接按照以下格式组装所需的API链接
提取IP接口
http://api.haiwaidaili.net/abroad?token=[APPKEY]&num=1&format=1&protocol=http&country=&sep=1&csep=
添加白名单接口
https://haiwaidaili.net/index/user/save_white/appid/[APPID]/appkey/[APPKEY].html?white=您的ip
删除白名单接口
https://haiwaidaili.net/index/user/del_white/appid/[APPID]/appkey/[APPKEY].html?white=您的ip
获取白名单接口
https://haiwaidaili.net/index/user/white_list/appid/[APPID]/appkey/[APPKEY].html?format=simple
住宅IP
动态机房IP
HTTP/HTTPS
SOCKS5
代理服务器 | 端口 | ||
子账号 | 当前密码 |
*由於政策原因,此服務建議在非中國大陸網絡環境下使用,感謝您的理解!
参数注释:
名称 | 类型 | 必选 | 说明 |
country | string | 否 | 国家代码标识 |
session | string | 否 | 需要固定一个ip时配置,用户自定义,注意:需由1-32位数字组成,不然会断网。 |
USERNAME | string | 否 | 子账号名称 |
PASWORD | string | 否 | 子账号密码 |
type | string | 否 | 固定为dc ,表示使用动态机房IP |
·用子账号访问动态住宅的账密格式
user-USERNAME-country-COUNTRYCODE-session-SESSION:PASWORD 其中: USERNAME: 子账号名称, COUNTRYCODE: 国家代码 SESSION: sessionid 有32位以内的随机数组成 PASWORD: 子账号密码 示例: # 访问美国 curl --socks5 user-sub.[USERNAME]-country-us-session-SESSION:[PASSWORD]@proxy.haiwai-ip.com:1456 "http://ip123.in/ip.json" -vv
·用子账号访问动态机房的账密格式
user-USERNAME-country-COUNTRYCODE-session-SESSION-type-dc:PASWORD 其中: USERNAME: 子账号名称, COUNTRYCODE: 国家代码 SESSION: sessionid 由32位以内的随机数组成 PASWORD: 子账号密码 type: 固定为dc ,表示使用动态机房IP 示例: # 访问美国 固定出口IP curl --socks5 user-sub.[USERNAME]-country-us-session-123456-type-dc:[PASSWORD]@proxy.haiwai-ip.com:1456 "http://ip123.in/ip.json" -vv
实例:
// demo.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "curl/curl.h" #pragma comment(lib, "libcurl.lib") static size_t write_buff_data(char *buffer, size_t size, size_t nitems, void *outstream) { memcpy(outstream, buffer, nitems*size); return nitems*size; } /* ʹ使用http代理 */ int GetUrlHTTP(char *url, char *buff) { CURL *curl; CURLcode res; curl = curl_easy_init(); if (curl) { curl_easy_setopt(curl, CURLOPT_PROXY,"http://测试ip:端口"); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)buff); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_buff; curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L); curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 50L); curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, 2000000L) res = curl_easy_perform(curl); curl_easy_cleanup(curl); if (res == CURLE_OK){ return res; }else { printf("错误代码:%d\n", res); MessageBox(NULL, TEXT("获取IP错误"), TEXT("MB_ICONINFORMATION | MB_YESNO); } } return res; } /* ʹ使用socks5代理 */ int GetUrlSocks5(char *url, char *buff) { CURL *curl; CURLcode res; curl = curl_easy_init(); if (curl) { curl_easy_setopt(curl, CURLOPT_PROXY, "socks5://测试ip:代理"); curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)buff); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_buff; curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L); curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 50L); curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, 200; res = curl_easy_perform(curl); curl_easy_cleanup(curl); if (res == CURLE_OK) { return res; } else { printf("错误代码:%d\n", res); MessageBox(NULL, TEXT("获取IP错误"), TEXT("MB_ICONINFORMATION | MB_YESNO); } } return res; } int GetUrl(char *url, char *buff) { CURL *curl; CURLcode res; curl = curl_easy_init(); if (curl) { curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void*)buff); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_buff; curl_easy_setopt(curl, CURLOPT_URL, url); curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 10L); curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 50L); curl_easy_setopt(curl, CURLOPT_MAX_RECV_SPEED_LARGE, 200; res = curl_easy_perform(curl); curl_easy_cleanup(curl); if (res == CURLE_OK) { return res; } else { printf("错误代码:%d\n", res); MessageBox(NULL, TEXT("获取IP错误"), TEXT("MB_ICONINFORMATION | MB_YESNO); } } return res; } int main() { char *buff=(char*)malloc(1024*1024); memset(buff, 0, 1024 * 1024); GetUrl("http://baidu.com", buff); printf("不使用代理%s\n", buff); memset(buff, 0, 1024 * 1024); GetUrlHTTP("http://baidu.com", buff); printf("http结果%s\n", buff); memset(buff, 0,1024 * 1024); GetUrlSocks5("http://baidu.com", buff); printf("socks5结果%s\n", buff); Sleep(1000 * 1000); free(buff); return 0; }
实例:
package main import ( "fmt" "io/ioutil" "net/http" "net/url" ) //sock5代理 func socksproxy() { urli := url.URL{} urlproxy, _ := urli.Parse("http://测试ip:端口") client := &http.Client{ Transport: &http.Transport{ Proxy: http.ProxyURL(urlproxy), }, } rqt, err := http.NewRequest("GET", "http://myip.top", nil) if err != nil { println("接口获取IP失败!") return } rqt.Header.Add("User-Agent", "Lingjiang") //处理返回结果 response, _ := client.Do(rqt) defer response.Body.Close() body, err := ioutil.ReadAll(response.Body) if err != nil { return } fmt.Println("socks5:", string(body)) return } //http代理 func httpproxy() { urli := url.URL{} urlproxy, _ := urli.Parse("http://测试ip:端口") client := &http.Client{ Transport: &http.Transport{ Proxy: http.ProxyURL(urlproxy), }, } rqt, err := http.NewRequest("GET", "http://myip.top", nil) if err != nil { println("接口获取IP失败!") return } rqt.Header.Add("User-Agent", "Lingjiang") //处理返回结果 response, _ := client.Do(rqt) defer response.Body.Close() body, err := ioutil.ReadAll(response.Body) if err != nil { return } fmt.Println("http:", string(body)) return } //本机IP func httplocal() { client := &http.Client{} rqt, err := http.NewRequest("GET", "http://myip.top", nil) if err != nil { println("接口获取IP失败!") return } rqt.Header.Add("User-Agent", "Lingjiang") //处理返回结果 response, _ := client.Do(rqt) defer response.Body.Close() body, err := ioutil.ReadAll(response.Body) if err != nil { return } fmt.Println("本机:", string(body)) return } func main() { httplocal() httpproxy() socksproxy() }
实例:
//node代理请求http var http = require('http') var opt = { host: 'tunnel.alicloudecs.com',//这里放代理服务器的ip或者域名 port: '500',//这里放代理服务器的端口号 method: 'GET',//这里是发送的方法 path: 'http://www.sdip.321174.com/', //这里是访问的路径 } //以下是接收数据的代码 var body = ''; var req = http.request(opt, function (res) { console.log("Got response: " + res.statusCode); res.on('data', function (d) { body += d; }).on('end', function () { console.log(res.headers) console.log(body) }); }).on('error', function (e) { console.log("Got error: " + e.message); }) req.end(); //node代理请求http/https const fetch = require("node-fetch"); const HttpsProxyAgent = require('https-proxy-agent'); //这里是访问的路径 let url="https://www.baidu.com/s?cl=3&tn=baidutop10&fr=top1000&wd=%E9%AB%98%E8%80%83&rsv_idx=2&rsv_dl=fyb_n_homepage&hisfilter=1"; //这是代理服务器地址 let ip='58.218.205.48'; //这是端口号 let port='500'; fetch(url, { method: 'GET', // body: null, agent: new HttpsProxyAgent("http://" + ip + ":" + port) //<==注意是 `http://` }).then(function (res) { console.log("Response Headers ============ "); res.headers.forEach(function(v,i,a) { console.log(i+" : "+v); }); return res.text(); }).then(function (res) { console.log("Response Body ============ "); console.log(res); });
实例:
Php http/sock5: // 要访问的目标页面 $targetUrl = "http://baidu.com"; // 代理服务器 $proxyServer = "http://ip:port"; // 隧道身份信息 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $targetUrl); curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, false); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 设置代理服务器 // curl_setopt($ch, CURLOPT_PROXYTYPE, 0); //http curl_setopt($ch, CURLOPT_PROXYTYPE, 5); //sock5 curl_setopt($ch, CURLOPT_PROXY, $proxyServer); // 设置隧道验证信息 curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 60; Windows NT 5.1; SV1; .NET CLR 2.0.50727;)"); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3); curl_setopt($ch, CURLOPT_TIMEOUT, 5); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $result = curl_exec($ch); curl_close($ch); var_dump($result);
HttpClient:
import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; import org.apache.http.HttpEntity; import org.apache.http.HttpHost; import org.apache.http.NameValuePair; import org.apache.http.client.config.RequestConfig; import org.apache.http.client.entity.UrlEncodedFormEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.message.BasicNameValuePair; import org.apache.http.util.EntityUtils; public class ClientProxyHttpClientHttp { // 代理服务器 final static String proxyHost = "xxx"; final static Integer proxyPort = 0; private static HttpHost proxy = null; private static RequestConfig reqConfig = null; static { proxy = new HttpHost(proxyHost, proxyPort, "http"); reqConfig = RequestConfig.custom().setConnectionRequestTimeout(5000).setConnectTimeout(10000) // 设置连接超时时间 .setSocketTimeout(10000) // 设置读取超时时间 .setExpectContinueEnabled(false).setProxy(new HttpHost(proxyHost, proxyPort)) .setCircularRedirectsAllowed(true) // 允许多次重定向 .build(); } public static void main(String[] args) { doGetRequest(); doPostRequest(); } public static void doGetRequest() { // 目标地址 String targetUrl = "http://httpbin.org/get"; try { // 设置url参数 (可选) Map urlParams = new HashMap<>(); urlParams.put("uid", "1234567"); String paramStr = EntityUtils.toString(new UrlEncodedFormEntity(paramsAdapter(urlParams), "UTF-8")); HttpGet httpGet = new HttpGet(targetUrl + "?" + paramStr); String result = doRequest(httpGet); System.out.println(result); } catch (Exception e) { e.printStackTrace(); } } public static void doPostRequest() { try { // 要访问的目标页面 HttpPost httpPost = new HttpPost("http://httpbin.org/post"); // 设置表单参数 Map formParams = new HashMap<>(); formParams.put("uid", "1234567"); UrlEncodedFormEntity uefEntity = new UrlEncodedFormEntity(paramsAdapter(formParams), "utf-8"); httpPost.setEntity(uefEntity); String result = doRequest(httpPost); System.out.println(result); } catch (Exception e) { e.printStackTrace(); } } /** * 设置请求头 * * @param httpReq */ private static void setHeaders(HttpRequestBase httpReq) { httpReq.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36"); httpReq.addHeader("xxx", "xxx"); } /** * 执行请求 * * @param httpReq * @return */ public static String doRequest(HttpRequestBase httpReq) { String result = new String(); httpReq.setConfig(reqConfig); try { // 设置请求头 setHeaders(httpReq); CloseableHttpClient httpClient = HttpClients.createDefault(); // 执行请求 CloseableHttpResponse httpResp = httpClient.execute(httpReq); // 保存Cookie // 获取http code int statusCode = httpResp.getStatusLine().getStatusCode(); System.out.println(statusCode); HttpEntity entity = httpResp.getEntity(); if (entity != null) { result = EntityUtils.toString(entity, "utf-8"); } httpResp.close(); httpClient.close(); httpReq.abort(); } catch (Exception e) { e.printStackTrace(); return null; } return result; } /** * 参数适配器,将系统定义的请求参数转换成HttpClient能够接受的参数类型 * * @param params * 系统定义的请求参数 * @return HttpClient要求的参数类型 */ private static List paramsAdapter(Map map) { List nvps = new ArrayList(); for (Entry entry : map.entrySet()) { nvps.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); } return nvps; } }
http:
import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.Authenticator; import java.net.InetSocketAddress; import java.net.PasswordAuthentication; import java.net.Proxy; import java.net.URL; import java.net.URLConnection; import java.nio.charset.StandardCharsets; /** * * @author librabin * */ public class ClientProxyBasicHttp { public static void main(String args[]) throws Exception { // 目标地址 String targetUrl = "http://httpbin.org/get"; // 代理服务器 String proxyHost = "xxx"; int proxyPort = 0; // http代理: Proxy.Type.HTTP, socks代理: Proxy.Type.SOCKS Proxy.Type proxyType = Proxy.Type.HTTP; // 代理验证 String proxyUser = "xxx"; String proxyPwd = "xxx"; try { // 设置验证 Authenticator.setDefault(new ProxyAuthenticator(proxyUser, proxyPwd)); // 创建代理服务器 InetSocketAddress addr = new InetSocketAddress(proxyHost, proxyPort); Proxy proxy = new Proxy(proxyType, addr); // 访问目标网页 URL url = new URL(targetUrl); URLConnection conn = url.openConnection(proxy); // 读取返回数据 InputStream in = conn.getInputStream(); // 将返回数据转换成字符串 System.out.println(IO2String(in)); } catch (Exception e) { e.printStackTrace(); } } /** * 将输入流转换成字符串 * * @param inStream * @return * @throws IOException */ public static String IO2String(InputStream inStream) throws IOException { ByteArrayOutputStream result = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len; while ((len = inStream.read(buffer)) != -1) { result.write(buffer, 0, len); } String str = result.toString(StandardCharsets.UTF_8.name()); return str; } static class ProxyAuthenticator extends Authenticator { private String authUser, authPwd; public ProxyAuthenticator(String authUser, String authPwd) { this.authUser = authUser; this.authPwd = authPwd; } public PasswordAuthentication getPasswordAuthentication() { return (new PasswordAuthentication(authUser, authPwd.toCharArray())); } } }
socks5:
import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.InetSocketAddress; import java.net.Proxy; import java.net.URL; import java.net.URLConnection; import java.nio.charset.StandardCharsets; /** * * @author librabin * */ public class ClientProxyBasicSocks { public static void main(String args[]) throws Exception { // 目标地址 String targetUrl = "http://httpbin.org/get"; // 代理服务器 String proxyHost = "xxx"; int proxyPort = 0; // http代理: Proxy.Type.HTTP, socks代理: Proxy.Type.SOCKS Proxy.Type proxyType = Proxy.Type.SOCKS; try { // 创建代理服务器 InetSocketAddress addr = new InetSocketAddress(proxyHost, proxyPort); Proxy proxy = new Proxy(proxyType, addr); // 访问目标网页 URL url = new URL(targetUrl); URLConnection conn = url.openConnection(proxy); // 读取返回数据 InputStream in = conn.getInputStream(); // 将返回数据转换成字符串 System.out.println(IO2String(in)); } catch (Exception e) { e.printStackTrace(); } } /** * 将输入流转换成字符串 * * @param inStream * @return * @throws IOException */ public static String IO2String(InputStream inStream) throws IOException { ByteArrayOutputStream result = new ByteArrayOutputStream(); byte[] buffer = new byte[1024]; int len; while ((len = inStream.read(buffer)) != -1) { result.write(buffer, 0, len); } String str = result.toString(StandardCharsets.UTF_8.name()); return str; } }
实例:
Python http/sock5: #coding=utf-8 import requests #请求地址 targetUrl = "http://baidu.com" #代理服务器 proxyHost = "ip" proxyPort = "port" proxyMeta = "http://%(host)s:%(port)s" % { "host" : proxyHost, "port" : proxyPort, } #pip install -U requests[socks] socks5代理 # proxyMeta = "socks5://%(host)s:%(port)s" % { # "host" : proxyHost, # "port" : proxyPort, # } proxies = { "http" : proxyMeta, } resp = requests.get(targetUrl, proxies=proxies) print resp.status_code print resp.text
实例:
Python selenium http/socks5: #coding=utf-8 from selenium import webdriver # 代理服务器 proxyHost = "ip" proxyPort = "port" proxyType='http' #socks5 # 代理隧道验证信息 service_args = [ "--proxy-type=%s" % proxyType, "--proxy=%(host)s:%(port)s" % { "host" : proxyHost, "port" : proxyPort, } ] # 要访问的目标页面 targetUrl = "http://baidu.com" driver = webdriver.PhantomJS(service_args=service_args) driver.get(targetUrl) print driver.title print driver.page_source.encode("utf-8") driver.quit()
电话客服
微信客服