1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
package javaapplication1;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) throws Exception
{
HttpURLConnection conn;
String line, htmlLine, html = "", post;
String headersNames[] = {
"Host",
"User-Agent",
"Accept",
"Accept-Language",
"Accept-Encoding",
"Accept-Charset",
"Keep-Alive",
"Connection",
"Referer",
"Cache-Control",
"Pragma",
"Cookie"
};
String headers[] = {
"darkpi.100webspace.net",
"Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.5",
"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3",
"ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"gzip,deflate",
"300",
"keep-alive",
"", // referer
"no-cache",
"no-cache",
""
};
BufferedReader reader;
OutputStreamWriter writer;
URL url;
post = URLEncoder.encode("darrylsite","UTF-8") + "=" + URLEncoder.encode("darrylsite","UTF-8") + "&" + URLEncoder.encode("***","UTF-8") + "=" + URLEncoder.encode("****","UTF-8");
url = new URL("http://darkpi.100webspace.net/");
conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
for(int i=0;i<headers.length;i++)
{
conn.setRequestProperty(headersNames[i], headers[i]);
}
conn.setDoOutput(true);
writer = new OutputStreamWriter(conn.getOutputStream());
writer.write(post);
writer.close();
conn.connect();
reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
while((htmlLine = reader.readLine()) != null) {
html += "\n" + htmlLine;
}
reader.close();
System.out.println(html);
conn.disconnect();
}
} |
Partager