注册
登录
 文档中心 产品介绍 开发指南 API接口 代码样例 使用帮助
使用Java通过API接口获取代理IP的代码样例
站大爷 官方 2024-01-20 1833 浏览

温馨提示:

1.  运行环境要求 jdk >= 1.6


/**
 * 使用jdk原生库调用API
 */
public class TestAPI {

	private static String apiUrl = "http://www.***.com/ShortProxy/GetIP/?api=1234567890&akey=8a17ca305f683620&count=1&timespan=3&type=3" //API链接

	public static void main(String[] args) {
		HttpRequest request = new HttpRequest();
		Map<String, String> headers = new HashMap<String, String>();
		headers.put("Accept-Encoding", "gzip"); //使用gzip压缩传输数据让访问更快
		try{
			HttpResponse response = request.sendGet(apiUrl, null, headers, null);
			System.out.println(response.getCode());
			System.out.println(response.getContent());
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}


立即注册站大爷用户,免费试用全部产品
立即注册站大爷用户,免费试用全部产品