服务条款 常见问题 知识库 每日IP更新 IP实时分布
登录 注册

1. 建议爬虫用户使用动态代理IP,同时支持Http、Https协议,所有IP均为国内高匿 + 可用率95%以上 + 平均12M带宽

2. 动态代理API接口限制每秒钟最多请求10次,超过10次返回为空,HTTP状态码429。休眠1秒后自动恢复。

3. 购买前请做好测试,交易后不支持退款。如需测试请购买套餐一  下载动态代理IP测试DEMO项目(Java版)  

4. 累计消费满1000元可以开增值税普通发票,发票类型:技术服务费。

购买动态代理IP套餐

套餐类型 可使用时间 每次接口返回IP个数 预计可用IP量 IP有效期 原价 优惠价 购买
套餐一·测试 4小时 - + 15000 左右 9.6 4.0 续费充值
套餐二·包天 24小时 - + 15000 左右 24.0 10.0 续费充值
套餐三·包月 31天 - + 15000 左右 384.0 160.0 续费充值
套餐四·包季度 93天 - + 15000 左右 960.0 400.0 续费充值
套餐五·包半年 180天 - + 15000 左右 1680.0 700.0 续费充值
套餐六·包年 365天 - + 15000 左右 3000.0 1250.0 续费充值
注:如点击“续费充值”按钮无反应,请按住Ctrl+F5刷新本页面即可。

动态代理效果演示(用JAVA测试)

>>点击观看效果动画<<

  • Java 代码示例
  • C# 代码示例
  • PHP 代码示例
  • Python 代码示例

下载完整工程(Maven版)   下载完整工程(带所需jar包)   下载所需jar包  


package com.goubanjia.test;

import java.io.BufferedInputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.util.ArrayList;
import java.util.List;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.ProxyConfig;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;

/**
 * 这个DEMO主要为了测试动态代理IP的稳定性
 * 也可以作为爬虫参考项目,如需使用,请自行修改代码webParseHtml方法
 */
public class TestDynamicIp {
	public static List ipList = new ArrayList<>();
	public static boolean gameOver = false;
	public static void main(String[] args) {
		long fetchIpSeconds = 5;
		int threadNum = 10;
		int testTime = 3;
		// 请填写全网代理IP订单号,填写之后才可以提取到IP哦
		String order = "一定要把这里改为单号哦~";
		// 你要抓去的目标网址
		String targetUrl = "http://1212.ip138.com/ic.asp";
		// 是否加载JS,加载JS会导致速度变慢
		boolean useJS = false;
		// 请求超时时间,单位毫秒,默认5秒
		int timeOut = 5000;
		
		if (order == null || "".equals(order)) {
			System.err.println("请输入全网代理IP动态代理订单号");
			return;
		}
		
		System.out.println(">>>>>>>>>>>>>>全网代理动态IP测试开始<<<<<<<<<<<<<<");
		System.out.println("***************");
		System.out.println("接口返回IP为国内各地区,每次最多返回10个");
		System.out.println("提取IP间隔 " + fetchIpSeconds + " 秒 ");
		System.out.println("开启爬虫线程 " + threadNum);
		System.out.println("爬虫目标网址  " + targetUrl);
		System.out.println("测试次数 3 ");
		System.out.println("***************\n");
		TestDynamicIp tester = new TestDynamicIp();
		new Thread(tester.new GetIP(fetchIpSeconds * 1000, testTime, order)).start();
		for (int i = 0; i < threadNum; i++) {
			tester.new Crawler(100, targetUrl, useJS, timeOut).start();
		}
		while(!gameOver){
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		System.out.println(">>>>>>>>>>>>>>全网代理动态IP测试结束<<<<<<<<<<<<<<");
		System.exit(0);
	}
    
	// 抓取目标站,检测IP
	public class Crawler extends Thread{
		@Override
		public void run() {
			while(!gameOver){
				webParseHtml(targetUrl);
				try {
					Thread.sleep(sleepMs);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
		
		long sleepMs = 200;
		boolean useJs = false;
		String targetUrl = "";
		int timeOut = 5000;
		
		public Crawler(long sleepMs, String targetUrl, boolean useJs, int timeOut) {
			this.sleepMs = sleepMs;
			this.targetUrl = targetUrl;
			this.useJs = useJs;
			this.timeOut = timeOut;
		}
		public String webParseHtml(String url) {
			String html = "";
			BrowserVersion[] versions = {BrowserVersion.INTERNET_EXPLORER_11, BrowserVersion.CHROME, BrowserVersion.FIREFOX_38, BrowserVersion.INTERNET_EXPLORER_8};
			WebClient client = new WebClient(versions[(int)(versions.length * Math.random())]);
			try {
				client.getOptions().setThrowExceptionOnFailingStatusCode(false);
				client.getOptions().setJavaScriptEnabled(useJs);
				client.getOptions().setCssEnabled(false);
				client.getOptions().setThrowExceptionOnScriptError(false);
				client.getOptions().setTimeout(timeOut);
				client.getOptions().setAppletEnabled(true);
				client.getOptions().setGeolocationEnabled(true);
				client.getOptions().setRedirectEnabled(true);
				// 这行代码允许访问HTTPS网站
				client.getOptions().setUseInsecureSSL(true);
				
				String ipport = getAProxy();
				if (ipport != null) {
					ProxyConfig proxyConfig = new ProxyConfig(ipport.split(":")[0], Integer.parseInt(ipport.split(":")[1]));
					client.getOptions().setProxyConfig(proxyConfig);
				}else {
					System.out.print(".");
					return "";
				}
			
				HtmlPage page = client.getPage(url);
				html = page.asXml();
				
				System.out.println(getName() + " 使用代理 " + ipport + "请求目标网址返回HTML:" + html);
				
			} catch (Exception e) {
				return webParseHtml(url);
			} finally {
				client.close();
			}
			return html;
		}
		
	    private String getAProxy() {
	    	if (ipList.size() > 0) {
	    		String ip = ipList.get((int)(Math.random() * ipList.size()));
	    		return ip ;
			}
			return null;
		}
	}
	
	// 定时获取动态IP
	public class GetIP implements Runnable{
		long sleepMs = 1000;
		int maxTime = 3;
		String order = "";
		
		public GetIP(long sleepMs, int maxTime, String order) {
			this.sleepMs = sleepMs;
			this.maxTime = maxTime;
			this.order = order;
		}
		
		@Override
		public void run() {
			long getIpTime = 0;
			int time = 1;
			while(!gameOver){
				if(time >= 4){
					gameOver = true;
					break;
				}
				try {
					java.net.URL url = new java.net.URL("http://dynamic.goubanjia.com/dynamic/get/" + order + ".html?ttl");
			    	HttpURLConnection connection = (HttpURLConnection)url.openConnection();
			    	connection.setConnectTimeout(3000);
			    	connection = (HttpURLConnection)url.openConnection();
			    	
			        InputStream raw = connection.getInputStream();  
			        InputStream in = new BufferedInputStream(raw);  
			        byte[] data = new byte[in.available()];
			        int bytesRead = 0;  
			        int offset = 0;  
			        while(offset < data.length) {  
			            bytesRead = in.read(data, offset, data.length - offset);  
			            if(bytesRead == -1) {  
			                break;  
			            }  
			            offset += bytesRead;  
			        }  
			        in.close();  
			        raw.close();
					String[] res = new String(data, "UTF-8").split("\n");
					List ipList = new ArrayList<>();
					for (String ip : res) {
						try {
							String[] parts = ip.split(",");
							if (Integer.parseInt(parts[1]) > 0) {
								ipList.add(parts[0]);
							}
						} catch (Exception e) {
						}
					}
					if (ipList.size() > 0) {
						TestDynamicIp.ipList = ipList;
						System.out.println("第" + ++getIpTime + "次获取动态IP " + ipList.size() + " 个");
						time += 1;
					}
				} catch (Exception e) {
					e.printStackTrace();
					System.err.println(">>>>>>>>>>>>>>获取IP出错");
				}
				try {
					Thread.sleep(sleepMs);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
	}
	
}


© 2015 版权所有   QQ交流群:66782959  每日免费分享  代理知识库   服务条款

声明:本站资源仅限用来计算机技术学习及大数据抓取、爬虫等合法行为,利用本站资源从事任何违反中国法律法规的行为,由此引起的一切后果与本站无关。