Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.77 KB | None | 0 0
  1. import org.jsoup.Jsoup;
  2. import org.jsoup.nodes.Document;
  3. import org.jsoup.nodes.Element;
  4.  
  5. import java.io.BufferedReader;
  6. import java.io.BufferedWriter;
  7. import java.io.File;
  8. import java.io.FileReader;
  9. import java.io.FileWriter;
  10. import java.io.IOException;
  11. import java.io.PrintWriter;
  12. import java.security.SecureRandom;
  13. import java.util.Arrays;
  14. import java.util.HashMap;
  15. import java.util.Map;
  16. import java.util.Scanner;
  17.  
  18. public class Main {
  19.  
  20. private static final String URL = "https://mafiareturns.com/news/uprofile.php?id=%s";
  21.  
  22. public static void main(String[] args) {
  23. String[] durd1 = {"1957608", "1958808"};
  24. String[] durd2 = {"1958826", "1958974"};
  25. String[] durd3 = {"1959005", "1961253"};
  26. // new Main().execute(durd1);
  27. // new Main().execute(durd2);
  28. // new Main().execute(durd3);
  29. new Main().execute2();
  30. }
  31.  
  32. private void execute(String[] args) {
  33. if (args.length != 2) {
  34. throw new RuntimeException();
  35. }
  36.  
  37. int min = Integer.parseInt(args[0]);
  38. int max = Integer.parseInt(args[1]);
  39.  
  40. try {
  41. File file = new File("C:\\Users\\stelios\\Desktop\\list.csv");
  42. FileWriter fr = new FileWriter(file, true);
  43. BufferedWriter br = new BufferedWriter(fr);
  44. PrintWriter pr = new PrintWriter(br);
  45.  
  46. int counter=0;
  47. SecureRandom r = new SecureRandom();
  48. int low = 220000;
  49. int high = 250000;
  50. for (int i = min; i <= max; i++) {
  51.  
  52. System.out.println(String.format("scanning id:%s", i));
  53. if (counter!=0&&counter%100==0){
  54. int duration = r.nextInt(high-low) + low;
  55. Thread.sleep(duration);
  56. }
  57. Element profile = getProfile(i);
  58.  
  59. if (getProt(profile)) {
  60. String url = String.format(URL, i);
  61. String name = getName(profile);
  62.  
  63. pr.println(String.format("%s,%s", name, url));
  64. pr.flush();
  65.  
  66. }
  67. counter++;
  68. }
  69. pr.close();
  70. br.close();
  71. fr.close();
  72.  
  73. } catch (IOException | InterruptedException e) {
  74. e.printStackTrace();
  75. }
  76. }
  77.  
  78. private boolean getProt(Element profile) throws IOException {
  79.  
  80. String bodyguards= profile.getElementsByClass("odd").get(1)
  81. .getElementsByTag("a").get(0)
  82. .text().trim();
  83. return bodyguards.contains("Slightly Protected");
  84. }
  85.  
  86. private void execute2() {
  87.  
  88. File list = new File("C:\\Users\\stelios\\Desktop\\oldlist.csv");
  89. int countera = 0;
  90. int linecounter = 0;
  91. try {
  92. Scanner inputStream = new Scanner(list);
  93. BufferedReader reader = new BufferedReader(new FileReader(list));
  94. while (reader.readLine() != null) countera++;
  95. reader.close();
  96.  
  97.  
  98.  
  99. String[][] values = new String[countera][];
  100.  
  101. while (inputStream.hasNext()) {
  102. String line[] = inputStream.nextLine().split(",");
  103.  
  104.  
  105. System.out.println(Arrays.toString(line));
  106.  
  107. values[linecounter]= line;
  108. linecounter++;
  109. System.out.println(line.length);
  110.  
  111. System.out.println(linecounter);
  112.  
  113.  
  114.  
  115.  
  116. }
  117. System.out.println("WE PRINT NOW");
  118. System.out.println(values[3][9]);
  119. System.out.println(values.length);
  120. System.out.println(countera);
  121.  
  122. inputStream.close();
  123.  
  124. File file = new File("C:\\Users\\stelios\\Desktop\\newlist.csv");
  125. FileWriter fr = new FileWriter(file, true);
  126. BufferedWriter br = new BufferedWriter(fr);
  127. PrintWriter pr = new PrintWriter(br);
  128.  
  129. int counter=0;
  130. SecureRandom r = new SecureRandom();
  131. int low = 220000;
  132. int high = 250000;
  133. for (int i = 3; i < values.length; i++) {
  134.  
  135. System.out.println(String.format("scanning id:%s", values[i][9]));
  136. if (counter!=0&&counter%100==0){
  137. int duration = r.nextInt(high-low) + low;
  138. Thread.sleep(duration);
  139. }
  140. Element profile = getProfile2(values[i][9]);
  141.  
  142. if (getProt(profile)) {
  143. String name = getName(profile);
  144.  
  145. pr.println(Arrays.toString(values[i]).replace("[","").replace("]",""));
  146.  
  147. pr.flush();
  148.  
  149. }
  150. counter++;
  151. }
  152. pr.close();
  153. br.close();
  154. fr.close();
  155.  
  156. } catch (IOException | InterruptedException e) {
  157. e.printStackTrace();
  158. }
  159. }
  160.  
  161. private String getName(Element profile){
  162. return profile.getElementsByClass("even").get(0)
  163. .getElementsByTag("a").get(0)
  164. .text().trim();
  165. }
  166.  
  167. private Element getProfile(int id) throws IOException {
  168. String url = String.format(URL, id);
  169. Map<String, String> loginCookies = new HashMap<>();
  170. loginCookies.put("PHPSESSID", "ladk3dp0298096hdjrd3erk0d5");
  171. loginCookies.put("__cfduid", "d8bb1f60c7ce8190811c8327c32dfbbee1544281209");
  172. loginCookies.put("_ga", "GA1.2.1891918505.1544281210");
  173. loginCookies.put("_gid", "GA1.2.1884826233.1547851943");
  174. loginCookies.put("io", "t-QFP75kwlqHBW-JAAT-");
  175. loginCookies.put("lounge_instance", "5");
  176. loginCookies.put("mr", "GA1.2.1661446064.1544281224");
  177. loginCookies.put("mr_gid", "GA1.2.1510258359.1547851945");
  178.  
  179. Document html= Jsoup.connect(url)
  180. .cookies(loginCookies)
  181. .timeout(5000)
  182. .get();
  183. return html.body().getElementById("profile");
  184. }
  185.  
  186. private Element getProfile2(String url) throws IOException {
  187. Map<String, String> loginCookies = new HashMap<>();
  188. loginCookies.put("PHPSESSID", "ladk3dp0298096hdjrd3erk0d5");
  189. loginCookies.put("__cfduid", "d8bb1f60c7ce8190811c8327c32dfbbee1544281209");
  190. loginCookies.put("_ga", "GA1.2.1891918505.1544281210");
  191. loginCookies.put("_gid", "GA1.2.1884826233.1547851943");
  192. loginCookies.put("io", "t-QFP75kwlqHBW-JAAT-");
  193. loginCookies.put("lounge_instance", "5");
  194. loginCookies.put("mr", "GA1.2.1661446064.1544281224");
  195. loginCookies.put("mr_gid", "GA1.2.1510258359.1547851945");
  196.  
  197. Document html= Jsoup.connect(url)
  198. .cookies(loginCookies)
  199. .timeout(5000)
  200. .get();
  201. return html.body().getElementById("profile");
  202. }
  203. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement