Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.jsoup.Jsoup;
- import org.jsoup.nodes.Document;
- import org.jsoup.nodes.Element;
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.security.SecureRandom;
- import java.util.Arrays;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Scanner;
- public class Main {
- private static final String URL = "https://mafiareturns.com/news/uprofile.php?id=%s";
- public static void main(String[] args) {
- String[] durd1 = {"1957608", "1958808"};
- String[] durd2 = {"1958826", "1958974"};
- String[] durd3 = {"1959005", "1961253"};
- // new Main().execute(durd1);
- // new Main().execute(durd2);
- // new Main().execute(durd3);
- new Main().execute2();
- }
- private void execute(String[] args) {
- if (args.length != 2) {
- throw new RuntimeException();
- }
- int min = Integer.parseInt(args[0]);
- int max = Integer.parseInt(args[1]);
- try {
- File file = new File("C:\\Users\\stelios\\Desktop\\list.csv");
- FileWriter fr = new FileWriter(file, true);
- BufferedWriter br = new BufferedWriter(fr);
- PrintWriter pr = new PrintWriter(br);
- int counter=0;
- SecureRandom r = new SecureRandom();
- int low = 220000;
- int high = 250000;
- for (int i = min; i <= max; i++) {
- System.out.println(String.format("scanning id:%s", i));
- if (counter!=0&&counter%100==0){
- int duration = r.nextInt(high-low) + low;
- Thread.sleep(duration);
- }
- Element profile = getProfile(i);
- if (getProt(profile)) {
- String url = String.format(URL, i);
- String name = getName(profile);
- pr.println(String.format("%s,%s", name, url));
- pr.flush();
- }
- counter++;
- }
- pr.close();
- br.close();
- fr.close();
- } catch (IOException | InterruptedException e) {
- e.printStackTrace();
- }
- }
- private boolean getProt(Element profile) throws IOException {
- String bodyguards= profile.getElementsByClass("odd").get(1)
- .getElementsByTag("a").get(0)
- .text().trim();
- return bodyguards.contains("Slightly Protected");
- }
- private void execute2() {
- File list = new File("C:\\Users\\stelios\\Desktop\\oldlist.csv");
- int countera = 0;
- int linecounter = 0;
- try {
- Scanner inputStream = new Scanner(list);
- BufferedReader reader = new BufferedReader(new FileReader(list));
- while (reader.readLine() != null) countera++;
- reader.close();
- String[][] values = new String[countera][];
- while (inputStream.hasNext()) {
- String line[] = inputStream.nextLine().split(",");
- System.out.println(Arrays.toString(line));
- values[linecounter]= line;
- linecounter++;
- System.out.println(line.length);
- System.out.println(linecounter);
- }
- System.out.println("WE PRINT NOW");
- System.out.println(values[3][9]);
- System.out.println(values.length);
- System.out.println(countera);
- inputStream.close();
- File file = new File("C:\\Users\\stelios\\Desktop\\newlist.csv");
- FileWriter fr = new FileWriter(file, true);
- BufferedWriter br = new BufferedWriter(fr);
- PrintWriter pr = new PrintWriter(br);
- int counter=0;
- SecureRandom r = new SecureRandom();
- int low = 220000;
- int high = 250000;
- for (int i = 3; i < values.length; i++) {
- System.out.println(String.format("scanning id:%s", values[i][9]));
- if (counter!=0&&counter%100==0){
- int duration = r.nextInt(high-low) + low;
- Thread.sleep(duration);
- }
- Element profile = getProfile2(values[i][9]);
- if (getProt(profile)) {
- String name = getName(profile);
- pr.println(Arrays.toString(values[i]).replace("[","").replace("]",""));
- pr.flush();
- }
- counter++;
- }
- pr.close();
- br.close();
- fr.close();
- } catch (IOException | InterruptedException e) {
- e.printStackTrace();
- }
- }
- private String getName(Element profile){
- return profile.getElementsByClass("even").get(0)
- .getElementsByTag("a").get(0)
- .text().trim();
- }
- private Element getProfile(int id) throws IOException {
- String url = String.format(URL, id);
- Map<String, String> loginCookies = new HashMap<>();
- loginCookies.put("PHPSESSID", "ladk3dp0298096hdjrd3erk0d5");
- loginCookies.put("__cfduid", "d8bb1f60c7ce8190811c8327c32dfbbee1544281209");
- loginCookies.put("_ga", "GA1.2.1891918505.1544281210");
- loginCookies.put("_gid", "GA1.2.1884826233.1547851943");
- loginCookies.put("io", "t-QFP75kwlqHBW-JAAT-");
- loginCookies.put("lounge_instance", "5");
- loginCookies.put("mr", "GA1.2.1661446064.1544281224");
- loginCookies.put("mr_gid", "GA1.2.1510258359.1547851945");
- Document html= Jsoup.connect(url)
- .cookies(loginCookies)
- .timeout(5000)
- .get();
- return html.body().getElementById("profile");
- }
- private Element getProfile2(String url) throws IOException {
- Map<String, String> loginCookies = new HashMap<>();
- loginCookies.put("PHPSESSID", "ladk3dp0298096hdjrd3erk0d5");
- loginCookies.put("__cfduid", "d8bb1f60c7ce8190811c8327c32dfbbee1544281209");
- loginCookies.put("_ga", "GA1.2.1891918505.1544281210");
- loginCookies.put("_gid", "GA1.2.1884826233.1547851943");
- loginCookies.put("io", "t-QFP75kwlqHBW-JAAT-");
- loginCookies.put("lounge_instance", "5");
- loginCookies.put("mr", "GA1.2.1661446064.1544281224");
- loginCookies.put("mr_gid", "GA1.2.1510258359.1547851945");
- Document html= Jsoup.connect(url)
- .cookies(loginCookies)
- .timeout(5000)
- .get();
- return html.body().getElementById("profile");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement