public static void main(String[] args) throws ClientProtocolException, IOException, InterruptedException {
		// 读取配置文件
		Properties config = new Properties();
		config.load(new FileInputStream(GreatCustomerBak.class.getResource("/").getFile() + "config.properties"));
		// 读取代理列表文件地址
		String proxyListFile = config.getProperty("proxylist.list");
		// 读取最高延迟时间
		int maxdelay = Integer.parseInt(config.getProperty("client.maxdelay", "5"));

		// 读取代理列表
		System.out.println("开始读取代理文件");
		BufferedReader reader = new BufferedReader(new FileReader(GreatCustomerBak.class.getResource("/").getFile() + proxyListFile));
		String nextLine = null;
		List<Proxy> proxyList = new ArrayList<Proxy>();
		while ((nextLine = reader.readLine()) != null) {
			try {
				if (!"".equals(nextLine.trim())) {

					Proxy proxyConfig = new Proxy();
//					proxyConfig.setHost(nextLine.split("\\s")[0]);
//					proxyConfig.setPort(Integer.parseInt(nextLine.split("\\s")[1]));
					proxyConfig.setHost(nextLine.split("\\s")[0].split(":")[0]);
					proxyConfig.setPort(Integer.parseInt(nextLine.split("\\s")[0].split(":")[1]));
					proxyList.add(proxyConfig);
				}
			} catch (Exception e) {
				// 若处理中出现问题则跳过此行
				continue;
			}
		}
		reader.close();
		System.out.println("代理文件获取完毕，共获取代理[" + proxyList.size() + "]个");

		// 连接流程
		System.out.println("开始组装链接");
		HttpClient client = new DefaultHttpClient();
		client.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, 3000);
		client.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 3000);
		
		// 设置投票地址
		String host = "http://r.gnavi.co.jp/enz725uz0000/menu4/";
		HttpGet method = new HttpGet(host);
		System.out.println("目标[" + host + "]");

		// 伪装头信息
		method.setHeader("Accept", "*/*");
		method.setHeader("Accept-Encoding", "gzip, deflate");
		method.setHeader("Cache-Control", "no-cache");
		method.setHeader("Connection", "keep-alive");
		// method.setHeader("Content-Length", "18");
		method.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
		method.setHeader("Pragma", "no-cache");
		method.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0");
		method.setHeader("X-Requested-With", "XMLHttpRequest");

		// 遍历代理列表进行发送
		System.out.println("开始遍历请求过程");
		int count = 0;
		for (int i = 0; i < proxyList.size(); i++) {
			// 设置代理
			Proxy proxyConfig = proxyList.get(i);
			System.out.print((i + 1) + ".当前代理[" + proxyConfig + "]");
			HttpHost proxy = new HttpHost(proxyConfig.getHost(), proxyConfig.getPort());
			client.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY, proxy);
			// 测试代理
			boolean enable = false;
			try {
				HttpGet testMethod = new HttpGet("http://www.baidu.com");
				HttpResponse testResponse = client.execute(testMethod);
				if (testResponse.getStatusLine().getStatusCode() == 200) {
					enable = true;
				} else {
					System.out.print("\t代理测试不可用");
				}
				testMethod.releaseConnection();
			} catch (Exception e) {
				System.out.print("\t代理测试不可用");
			}
			// 测试通过后，开始发送
			if (enable) {
				try {
					HttpResponse response = client.execute(method);
					// 打印输出
					// System.out.println(response.getStatusLine().getStatusCode());
					// 获取结果
					if (response.getStatusLine().getStatusCode() == 200) {
						System.out.print("\t投票成功");
						count++;
					} else {
						System.out.print("\t投票失败:" + response.getStatusLine().getStatusCode());
//						if (response.getStatusLine().getStatusCode() == 500) {
//							System.out.println(response.getEntity().getContentType().getValue());
//							System.out.println(EntityUtils.toString(response.getEntity(), "UTF-8"));
//						}
					}
					method.releaseConnection();
				} catch (Exception e) {
					System.out.print("\t代理异常");
				}
				// 计算伪装延迟
				int delay = (int) (Math.random() * (maxdelay + 1));
				System.out.print("\t[" + delay + "]秒后进行下一次请求");
				Thread.sleep(delay * 1000);
			}
			System.out.println();
		}

		// 处理结束，输出汇总信息
		System.out.println("遍历请求完成，成功次数[" + count + "]，实际增加可能小于此值");

	}