Guest User

Untitled

a guest
Aug 27th, 2012
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.56 KB | None | 0 0
  1. import java.io.*;
  2. import java.net.*;
  3. import java.util.*;
  4.  
  5.  
  6. public class whore
  7. {
  8. static HashMap<String, String> map2 = new HashMap<String, String>();
  9.    
  10.     public static void start(String[] urls, String cookies) throws Exception
  11.     {
  12.         ////////////////////
  13.         // HEADER CONTENT //
  14.         map2.put("(Request-Line", "POST /t*themanummer*,*beitragsnummer*.html HTTP/1.1");
  15.         map2.put("Host", "forum.geizhals.at");
  16.         // Was gehört hier her?
  17.         map2.put("User-Agent", "");
  18.         map2.put("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
  19.         map2.put("Accept-Language", "en-US,en;q=0.5");
  20.         map2.put("Accept-Encoding", "gzip, deflate");
  21.         map2.put("DNT", "1");
  22.         // Wird abgefragt, kein Problem.
  23.         map2.put("Cookie", cookies);
  24.         // Was gehört hier her?
  25.         map2.put("Connection", "keep.alive");
  26.         map2.put("Content-Type", "application/x-www-form-urlencoded");
  27.         // Ich habe keine Ahnung wie diese Zahl entsteht!
  28.         map2.put("Content-Length", "???");
  29.        
  30.         //////////////////
  31.         // POST Content //
  32.         map2.put("plonk", "true");
  33.         // Bei einem Plonk Befelhl werden auch immer die Werte x und y mitgeschickt.
  34.         // Was bedeuten sie?
  35.         // Sind sie wichtig?
  36.         map2.put("x", "???");
  37.         map2.put("y", "???");
  38.        
  39.        
  40.         letsgo(urls);
  41.         System.out.println("fertig");
  42.        
  43.     }
  44.  
  45.     public static void letsgo(String[] urls) throws Exception
  46.     {
  47.         int fivepercent = ( urls.length/20 );
  48.         int done = 0;
  49.        
  50.         for(int i = 0 ; i < urls.length; i++)
  51.         {
  52.             doSubmit(urls[i], map2);
  53.             if(i%fivepercent == 0)
  54.             {
  55.                 System.out.println(done + " Prozent abgeschlossen.");
  56.                 done += 5;
  57.             }
  58.         }
  59.     }
  60.  
  61.     public static void doSubmit(String url, Map<String, String> data) throws Exception
  62.     {
  63.        
  64.             URL siteUrl = new URL(url);
  65.             HttpURLConnection conn = (HttpURLConnection) siteUrl.openConnection();
  66.             conn.setRequestMethod("POST");
  67.             conn.setDoOutput(true);
  68.             conn.setDoInput(true);
  69.            
  70.             DataOutputStream out = new DataOutputStream(conn.getOutputStream());
  71.            
  72.             Set keys = data.keySet();
  73.             Iterator keyIter = keys.iterator();
  74.             String content = "";
  75.             for(int i=0; keyIter.hasNext(); i++) {
  76.                 Object key = keyIter.next();
  77.                 if(i!=0) {
  78.                     content += "&amp;";
  79.                 }
  80.                 content += key + "=" + URLEncoder.encode(data.get(key), "UTF-8");
  81.             }
  82.             //System.out.println(content);
  83.             out.writeBytes(content);
  84.             out.flush();
  85.             out.close();
  86.             BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  87.             //String line = "";
  88.             //while((line=in.readLine())!=null)
  89.             {
  90.                 //System.out.println(line);
  91.             }
  92.             in.close();
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment