Занимаюсь получением http запроса, я вроде как пробился на сайт, но получаю след ошибки:
Exception in thread "main" java.net.ProtocolException: Server redirected too many times (20)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1921)
at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1509)
at java.base/java.net.URL.openStream(URL.java:1117)
at Main.main(Main.java:13)
ВОТ КОД:
class Main {
public static void main(String[] argv) throws Exception {
Authenticator.setDefault(new MyAuthenticator());
URL url = new URL("")
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String str;
while((str = in.readLine()) != null) {
//System.out.println(str);
}
in.close();
}
}
class MyAuthenticator extends Authenticator {
protected PasswordAuthentication getPasswordAuthentication() {
String promptString = getRequestingPrompt();
System.out.println(promptString);
String hostname = getRequestingHost();
System.out.println(hostname);
InetAddress ipaddr = getRequestingSite();
System.out.println(ipaddr);
int port = getRequestingPort();
String username ="";
String password ="";
return new PasswordAuthentication(username, password.toCharArray());
}
}
Пароль, логин и сайт я спец убрал!!!!