Guest User

Untitled

a guest
Jul 27th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1. try {
  2.     HttpPost post = new HttpPost("http://www.derpforum.nl/?p=login");
  3.     List<NameValuePair> parameters = new ArrayList<>();
  4.     parameters.add(new BasicNameValuePair("username", "Kattoor4"));
  5.     parameters.add(new BasicNameValuePair("password", "deburen1995"));
  6.     parameters.add(new BasicNameValuePair("ip-check", "on"));
  7.     UrlEncodedFormEntity sendentity = new UrlEncodedFormEntity(parameters, HTTP.UTF_8);
  8.     post.setEntity(sendentity);
  9.  
  10.     CookieStore cookieStore = new BasicCookieStore();
  11.     HttpContext httpContext = new BasicHttpContext();
  12.     HttpClient client = new DefaultHttpClient();
  13.     httpContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
  14.  
  15.     HttpResponse response = client.execute(post, httpContext);
  16.     System.out.println(response.getStatusLine());
  17.  
  18.     EntityUtils.consume(response.getEntity());
  19.  
  20.     HttpGet get = new HttpGet("http://www.derpforum.nl");
  21.     response = client.execute(get, httpContext);
  22.  
  23.     BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
  24.     String line;
  25.     while ((line = reader.readLine()) != null)
  26.         System.out.println(line);
  27.  
  28. } catch (Exception e) {
  29.     e.printStackTrace();
  30. }
Advertisement
Add Comment
Please, Sign In to add comment