Advertisement
Guest User

pasta

a guest
Feb 4th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.10 KB | None | 0 0
  1. import org.jsoup.*;
  2. import org.jsoup.nodes.Document;
  3. import org.jsoup.nodes.Element;
  4. import sun.awt.image.SunVolatileImage;
  5.  
  6. /**
  7.  * Created by Andrzej on 2017-02-04.
  8.  */
  9. public class BetterVoter {
  10.  
  11.     private static final String USER_AGENT = "Mozilla/5.0";
  12.     private static final String SUNWELL = "http://sunwell.pl";
  13.     private static final String SUNWELL_LOGIN = "http://sunwell.pl/login";
  14.     private static final String SUNWELL_VOTE = "http://sunwell.pl/vote?is_jason_ajax=1";
  15.     private static final String SUNWELL_VOTE_POST = "http://sunwell.pl/vote/site";
  16.     private static final String USERNAME = "login";
  17.     private static final String PASSWORD = "password";
  18.     private static final String TOKEN = "5601b560b9ab1a56438945f8acf2d0ec";
  19.  
  20.     public static void main(String[] args) throws Exception {
  21.  
  22.  
  23.         Connection.Response loginForm = Jsoup.connect(SUNWELL)
  24.                 .userAgent("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21")
  25.                 .method(Connection.Method.GET)
  26.                 .execute();
  27.  
  28.         Connection.Response loginPage = Jsoup.connect(SUNWELL_LOGIN)
  29.                 .data("csrf_token_name", TOKEN)
  30.                 .data("login_username", USERNAME)
  31.                 .data("login_password", PASSWORD)
  32.                 .data("login_submit", "")
  33.                 .cookie("csrf_cookie_name", TOKEN)
  34.                 .method(Connection.Method.POST)
  35.                 .execute();
  36.  
  37.         Document doc = Jsoup.connect(SUNWELL_VOTE)
  38.                 .cookies(loginPage.cookies())
  39.                 .get();
  40.  
  41.         String vote_field_1 = doc.getElementById("vote_field_1").text();
  42.         String vote_field_2 = doc.getElementById("vote_field_2").text();
  43.  
  44.  
  45.  
  46.         System.out.println("TOPG.ORG: " + vote_field_1);
  47.         System.out.println("Top100Arena.com: " + vote_field_2);
  48.  
  49.         if(vote_field_1.contains("remaining") && vote_field_2.contains("remaining")) System.out.println("It seems you have already voted. I cannot vote now!");
  50.         else
  51.         {
  52.             System.out.println("Voting for the first one...");
  53.             Connection.Response votePage_vote_field_1 = Jsoup.connect(SUNWELL_VOTE_POST)
  54.                     .cookies(loginPage.cookies())
  55.                     .data("id" , "1")
  56.                     .data("csrf_token_name", TOKEN)
  57.                     .data("isFirefoxHerpDerp", "true")
  58.                     .method(Connection.Method.POST)
  59.                     .execute();
  60.  
  61.             System.out.println("Sleeping 3 seconds.");
  62.             Thread.sleep(3000);
  63.  
  64.             System.out.println("Voting for the second one...");
  65.             Connection.Response votePage_vote_field_2 = Jsoup.connect(SUNWELL_VOTE_POST)
  66.                     .cookies(loginPage.cookies())
  67.                     .data("id" , "2")
  68.                     .data("csrf_token_name", TOKEN)
  69.                     .data("isFirefoxHerpDerp", "true")
  70.                     .method(Connection.Method.POST)
  71.                     .execute();
  72.  
  73.             System.out.println("My job here is done. Have a good day! :)");
  74.         }
  75.  
  76.     }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement