it works!
This commit is contained in:
@@ -6,6 +6,7 @@ import java.io.InputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
@@ -29,6 +30,7 @@ public class CallerIdClient {
|
|||||||
try {
|
try {
|
||||||
login();
|
login();
|
||||||
getList();
|
getList();
|
||||||
|
// plainJava();
|
||||||
logout();
|
logout();
|
||||||
} catch (Exception e1) {
|
} catch (Exception e1) {
|
||||||
e1.printStackTrace();
|
e1.printStackTrace();
|
||||||
@@ -79,33 +81,148 @@ public class CallerIdClient {
|
|||||||
InputStream response = urlConn.getInputStream();
|
InputStream response = urlConn.getInputStream();
|
||||||
|
|
||||||
String r = new Scanner(response).useDelimiter("\\Z").next();
|
String r = new Scanner(response).useDelimiter("\\Z").next();
|
||||||
System.out.println(r);
|
log.info(r);
|
||||||
|
|
||||||
|
response.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void logout() throws Exception {
|
private void logout() throws Exception {
|
||||||
log.info("logout()");
|
log.info("logout()");
|
||||||
|
|
||||||
|
getUrl("https://speedport.ip/pub/info_status_de.xml");
|
||||||
|
|
||||||
|
|
||||||
|
URL url = new URL("https://speedport.ip/auth/logout.cgi?RequestFile=/pub/top_beenden.php&cookie=SessionID_R3," + cookie);
|
||||||
|
|
||||||
|
// URLConnection urlConn = url.openConnection();
|
||||||
|
// int statusA = urlConn.get
|
||||||
|
|
||||||
|
|
||||||
|
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
||||||
|
|
||||||
|
connection.setRequestMethod("POST");
|
||||||
|
connection.setInstanceFollowRedirects(false);
|
||||||
|
connection.setDoInput(true);
|
||||||
|
connection.setDoOutput(true);
|
||||||
|
connection.setUseCaches(false);
|
||||||
|
connection.setRequestProperty("Content-Length", "0");
|
||||||
|
connection.setRequestProperty("Cookie", "SessionID_R3=" + cookie);
|
||||||
|
connection.setRequestProperty("Referer", "https://speedport.ip/auth/hcti_status_telanrl.php?cookie=SessionID_R3," + cookie);
|
||||||
|
|
||||||
|
for (int i=0; ; i++) {
|
||||||
|
String headerName = connection.getHeaderFieldKey(i);
|
||||||
|
String headerValue = connection.getHeaderField(i);
|
||||||
|
|
||||||
|
if (headerName == null && headerValue == null) {
|
||||||
|
// No more headers
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (headerName == null) {
|
||||||
|
// The header value contains the server's HTTP version
|
||||||
|
log.info("Server HTTP version, Response code: " + headerValue);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log.info("Header: " + headerName + ", Value: " + headerValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
|
|
||||||
|
for (String line; (line = reader.readLine()) != null;) {
|
||||||
|
System.out.println("Answer: " + line);
|
||||||
|
}
|
||||||
|
|
||||||
|
int status = connection.getResponseCode();
|
||||||
|
log.info("POST Status: " + status);
|
||||||
|
|
||||||
|
reader.close();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// URL myUrl = new URL("https://speedport.ip/auth/logout.cgi?RequestFile=/pub/top_beenden.php&cookie=SessionID_R3," + cookie);
|
// URL myUrl = new URL("https://speedport.ip/auth/logout.cgi?RequestFile=/pub/top_beenden.php&cookie=SessionID_R3," + cookie);
|
||||||
URL myUrl = new URL("https://speedport.ip/auth/logout.cgi?cookie=SessionID_R3," + cookie);
|
//// URL myUrl = new URL("https://speedport.ip/auth/logout.cgi?cookie=SessionID_R3," + cookie);
|
||||||
String cookieString = "SessionID_R3=" + cookie;
|
// String cookieString = "SessionID_R3=" + cookie;
|
||||||
|
// URLConnection urlConn = myUrl.openConnection();
|
||||||
|
// urlConn.setRequestProperty("Cookie", cookieString);
|
||||||
|
// urlConn.setRequestProperty("Referer", "https://speedport.ip/auth/hcti_status_telanrl.php?cookie=SessionID_R3," + cookie);
|
||||||
|
// urlConn.connect();
|
||||||
|
// showStatus(urlConn);
|
||||||
|
//
|
||||||
|
URL myUrl = new URL("https://speedport.ip/");
|
||||||
URLConnection urlConn = myUrl.openConnection();
|
URLConnection urlConn = myUrl.openConnection();
|
||||||
urlConn.setRequestProperty("Cookie", cookieString);
|
urlConn.setRequestProperty("Cookie", "SessionID_R3=" + cookie);
|
||||||
urlConn.setRequestProperty("Referer", "https://speedport.ip/auth/hcti_status_telanrl.php?cookie=SessionID_R3," + cookie);
|
urlConn.setRequestProperty("Referer", "https://speedport.ip/auth/hcti_status_telanrl.php?cookie=SessionID_R3," + cookie);
|
||||||
urlConn.connect();
|
urlConn.connect();
|
||||||
showStatus(urlConn);
|
showStatus(urlConn);
|
||||||
|
|
||||||
myUrl = new URL("https://speedport.ip/");
|
getUrl("https://speedport.ip/pub/js_top_25.js");
|
||||||
urlConn = myUrl.openConnection();
|
|
||||||
urlConn.setRequestProperty("Cookie", cookieString);
|
|
||||||
urlConn.setRequestProperty("Referer", "https://speedport.ip/auth/hcti_status_telanrl.php?cookie=SessionID_R3," + cookie);
|
|
||||||
urlConn.connect();
|
|
||||||
showStatus(urlConn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getUrl(String urlString) throws Exception {
|
||||||
|
log.info("getUrl(" + urlString + ")");
|
||||||
|
|
||||||
|
URL url = new URL(urlString);
|
||||||
|
URLConnection conn = url.openConnection();
|
||||||
|
for (int i = 0; ; i++) {
|
||||||
|
String headerName = conn.getHeaderFieldKey(i);
|
||||||
|
String headerValue = conn.getHeaderField(i);
|
||||||
|
if (headerName == null && headerValue == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (headerName == null) {
|
||||||
|
log.info(" Server HTTP version, Response code: " + headerValue);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
log.info(" " + headerName + "=" + headerValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// URL url = new URL(urlString);
|
||||||
|
// URLConnection urlConn = url.openConnection();
|
||||||
|
// String cookieString = "SessionID_R3=" + cookie;
|
||||||
|
// urlConn.setRequestProperty("Cookie", cookieString);
|
||||||
|
// InputStream response = urlConn.getInputStream();
|
||||||
|
// String r = new Scanner(response).useDelimiter("\\Z").next();
|
||||||
|
// log.info(r);
|
||||||
|
// response.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void showStatus(URLConnection connection) throws IOException {
|
private void showStatus(URLConnection connection) throws IOException {
|
||||||
HttpURLConnection httpConnection = (HttpURLConnection) connection;
|
HttpURLConnection httpConnection = (HttpURLConnection) connection;
|
||||||
log.info("HTTP Status " + httpConnection.getResponseCode() + " - " + httpConnection.getURL());
|
log.info("HTTP Status " + httpConnection.getResponseCode() + " - " + httpConnection.getURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void plainJava() throws Exception {
|
||||||
|
|
||||||
|
URL url = new URL("https://speedport.ip/auth/logout.cgi?RequestFile=/pub/top_beenden.php&cookie=SessionID_R3," + cookie);
|
||||||
|
URLConnection conn = url.openConnection();
|
||||||
|
|
||||||
|
for (int i = 0;; i++) {
|
||||||
|
String name = conn.getHeaderFieldKey(i);
|
||||||
|
String value = conn.getHeaderField(i);
|
||||||
|
if (name == null && value == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (name == null) {
|
||||||
|
System.out.println("Server HTTP version, Response code:");
|
||||||
|
System.out.println(value);
|
||||||
|
System.out.print("\n");
|
||||||
|
} else {
|
||||||
|
System.out.println(name + "=" + value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Startseite
|
||||||
|
URL u = new URL("https://speedport.ip/");
|
||||||
|
String r = new Scanner(u.openStream()).useDelimiter("\\Z").next();
|
||||||
|
System.out.println(r);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param args
|
* @param args
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user