ipproxy123.com

smartproxy使用帮助文档java版本


Smartproxy提供了市场上7种最常用的编程语言的代码示例,包括Python,Node.js,Java,PHP,Ruby,C#,Go等多种语言,这里以java为例子。
import java.net.*;
import java.io.*;
import java.util.Scanner;
import java.net.*; import java.io.*; import java.util.Scanner;

public class ProxyTest { public static void main(String[] args) throws Exception { InetSocketAddress proxyAddress = new InetSocketAddress("gate.smartproxy.com", 7000); // Set proxy IP/port. Proxy proxy = new Proxy(Proxy.Type.HTTP, proxyAddress); URL url = new URL("http://ip.smartproxy.com/json"); //enter target URL Authenticator authenticator = new Authenticator() { public PasswordAuthentication getPasswordAuthentication() { return (new PasswordAuthentication("账号","密码".toCharArray())); //enter credentials } };

Authenticator.setDefault(authenticator); URLConnection urlConnection = url.openConnection(proxy);

//Scanner to view output

Scanner scanner = new Scanner(urlConnection.getInputStream()); System.out.println(scanner.next()); scanner.close(); }

}

InetSocketAddress proxyAddress = new InetSocketAddress("gate.smartproxy.com", 7000); // Set proxy IP/port. Proxy proxy = new Proxy(Proxy.Type.HTTP, proxyAddress); URL url = new URL("http://ip.smartproxy.com/json"); //enter target URL Authenticator authenticator = new Authenticator() { public PasswordAuthentication getPasswordAuthentication() { return (new PasswordAuthentication("账号","密码".toCharArray())); } }
«
Copyright © 2019 All Rights Reserved.