Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.jsoup.*;
- import org.jsoup.nodes.Document;
- import org.jsoup.nodes.Element;
- import sun.awt.image.SunVolatileImage;
- /**
- * Created by Andrzej on 2017-02-04.
- */
- public class BetterVoter {
- private static final String USER_AGENT = "Mozilla/5.0";
- private static final String SUNWELL = "http://sunwell.pl";
- private static final String SUNWELL_LOGIN = "http://sunwell.pl/login";
- private static final String SUNWELL_VOTE = "http://sunwell.pl/vote?is_jason_ajax=1";
- private static final String SUNWELL_VOTE_POST = "http://sunwell.pl/vote/site";
- private static final String USERNAME = "login";
- private static final String PASSWORD = "password";
- private static final String TOKEN = "5601b560b9ab1a56438945f8acf2d0ec";
- public static void main(String[] args) throws Exception {
- Connection.Response loginForm = Jsoup.connect(SUNWELL)
- .userAgent("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21")
- .method(Connection.Method.GET)
- .execute();
- Connection.Response loginPage = Jsoup.connect(SUNWELL_LOGIN)
- .data("csrf_token_name", TOKEN)
- .data("login_username", USERNAME)
- .data("login_password", PASSWORD)
- .data("login_submit", "")
- .cookie("csrf_cookie_name", TOKEN)
- .method(Connection.Method.POST)
- .execute();
- Document doc = Jsoup.connect(SUNWELL_VOTE)
- .cookies(loginPage.cookies())
- .get();
- String vote_field_1 = doc.getElementById("vote_field_1").text();
- String vote_field_2 = doc.getElementById("vote_field_2").text();
- System.out.println("TOPG.ORG: " + vote_field_1);
- System.out.println("Top100Arena.com: " + vote_field_2);
- if(vote_field_1.contains("remaining") && vote_field_2.contains("remaining")) System.out.println("It seems you have already voted. I cannot vote now!");
- else
- {
- System.out.println("Voting for the first one...");
- Connection.Response votePage_vote_field_1 = Jsoup.connect(SUNWELL_VOTE_POST)
- .cookies(loginPage.cookies())
- .data("id" , "1")
- .data("csrf_token_name", TOKEN)
- .data("isFirefoxHerpDerp", "true")
- .method(Connection.Method.POST)
- .execute();
- System.out.println("Sleeping 3 seconds.");
- Thread.sleep(3000);
- System.out.println("Voting for the second one...");
- Connection.Response votePage_vote_field_2 = Jsoup.connect(SUNWELL_VOTE_POST)
- .cookies(loginPage.cookies())
- .data("id" , "2")
- .data("csrf_token_name", TOKEN)
- .data("isFirefoxHerpDerp", "true")
- .method(Connection.Method.POST)
- .execute();
- System.out.println("My job here is done. Have a good day! :)");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement