折叠按钮
帮助中心
快速接入
1.提取代理IP列表

进入2808proxy后台->提取IP->一键生成提取IP列表的HTTP链接。

类似这种:https://api.2808proxy.com/proxy/unify/get?token=xxxxx&amount=1&proxy_type=http&format=json&splitter=rn&expire=300

浏览器访问后,您就可以获得您的IP:PORT了

需要注意, 这种方式是隐式地将请求API的本机IP加入到了白名单中,需要等待3~5分钟系统缓存刷新白名单,才可以正常连接代理。

返回值示例:

{
    "data": [{
        "s5_port_secured": 2082,
        "http_port": 8883,
        "s5_port": 2081,
        "id": "EXAMPLE_INTERFACE_ID",
        "http_port_secured": 8887,
        "ip": "1.2.3.4"
    }],
    "msg": null,
    "status": 0
}

返回参数说明

返回字段 数据类型 备注
http_port String HTTP(s)代理端口:使用白名单认证方式访问代理时使用此端口
http_port_secured String HTTP(s)代理端口:使用BasicAuth(用户名密码)认证方式访问代理时使用此端口
s5_port String Socks5代理端口:使用白名单认证方式访问代理时使用此端口
s5_port_secured String Socks5代理端口:使用BasicAuth(用户名密码)认证方式访问代理时使用此端口
2.使用代理IP

现在即可通过代理发送请求,http,socks5等均支持,很简单。

1.如果您无法编程,那么建议您配置"白名单"方式来使用代理IP,将您的每个服务器IP配置在“后台->白名单”即可,然后就可以通过IP:PORT来使用代理IP。。

2.如果您可以编程:

下面以使用代理访问 搜狐的IP接口为例。

python示例:


USERNAME = '您的账号'
PASSWORD = '您的密码'
getIPUrl= '您的一键生成提取IP的HTTP接口'

import requests
import time

if __name__=='__main__':

    #第一步:获取ip列表
    req = requests.get(getIPUrl)
    print(req.json)

    #第二步:通过代理ip发送请求
    proxy_url_secured = "%s://%s:%s@%s:%d" % ('http', USERNAME,PASSWORD,req['ip'], req['http_port_secured'])
    r = requests.get('http://pv.sohu.com/cityjson', proxies={'http':proxy_url_secured, 'https':proxy_url_secured})
    print("Response with proxy : " + r.text)
    print("sleeping...")
    time.sleep(1)

JAVA示例:

import com.proxy2808.client.Client;
import com.proxy2808.client.Proxy;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.params.ConnRoutePNames;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;

import java.io.IOException;

public class Demo {

    private static String username = "USERNAME";
    private static String password = "PASSWORD";
    private static URL url = new URL("您的一键提取IP的http地址");

    public static void main(String[] args) throws IOException {

       JSONObject result  =  getIPList(url);

       String ip  = result.getJSONArray("data").getgetJSONObject(0).getString("ip");
       String port = result.getJSONArray("data").getgetJSONObject(0).getString("http_port_secured")

       requestWithProxy(ip,port);
    }

  //第一步:获取代理IP列表
    public static JSONObject getIPList(URL url) {

            HttpClient httpclient = new DefaultHttpClient();
            HttpGet httpget = new HttpGet(url);
            JSONObject result; = JSONObject.parseObject(result);
            try {
                HttpResponse response = httpclient.execute(httpget);
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    result = JSONObject.parseObject(EntityUtils.toString(entity, "UTF-8").trim());
                }
            } catch (Exception e) {
                e.printStackTrace();
            }finally {
                httpget.abort();
            }
            return result;
        }


    //第二步:通过代理IP发送请求
    private static void requestWithProxy(String ipAddress,String ipPort) throws IOException {
        DefaultHttpClient httpclient = new DefaultHttpClient();

        httpclient.getCredentialsProvider().setCredentials(
                new AuthScope(yourIP, yourIPPort),
                new UsernamePasswordCredentials(username, password));

        HttpHost proxy = new HttpHost(yourIP, yourIPPort);

        httpclient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);

        HttpHost targetHost = new HttpHost("pv.sohu.com", 443, "https");

        HttpGet request = new HttpGet("/cityjson");

        try(CloseableHttpResponse response = httpclient.execute(targetHost, request)){
            System.out.println("Return status code is "+response.getStatusLine().getStatusCode());
            System.out.println("Return entity is "+EntityUtils.toString(response.getEntity()));
        }
    }

}

如上,即可方便快速使用代理IP全流程。