Guest User

Minecraft MP Ip Collector

a guest
Mar 22nd, 2015
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. package com.awsomeman.exus.mmp;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.io.PrintWriter;
  6.  
  7. import org.jsoup.Jsoup;
  8. import org.jsoup.nodes.Document;
  9. import org.jsoup.nodes.Element;
  10. import org.jsoup.select.Elements;
  11.  
  12. public class MMPExus {
  13.  
  14. private File ipFile;
  15. private PrintWriter writer;
  16.  
  17. public MMPExus() {
  18. int page = 0;
  19. ipFile = new File("C:/Users/Aaron/Documents/Research/mmp_ips.txt");
  20. try {
  21. writer = new PrintWriter(ipFile);
  22. writer.write("The list of ips:\n");
  23. // Needs to be updated as more servers are added.
  24. while(page <= 649) {
  25. page++;
  26. collectPageData(page);
  27. }
  28. } catch (IOException e) {
  29. e.printStackTrace();
  30. } finally {
  31. writer.close();
  32. }
  33. }
  34.  
  35. public void collectPageData(int page) {
  36. try {
  37. Document doc = Jsoup.connect("http://minecraft-mp.com/servers/list/" + page + "/").userAgent("Mozilla").get();
  38. Elements serverIp = doc.select("strong");
  39. for (Element link : serverIp) {
  40. /*
  41. * Data is stored in <strong> tags but so is the rank number
  42. * and the site name. This filters the data so we just have
  43. * the ip.
  44. */
  45. if(!link.toString().contains("#") && !link.toString().contains("Minecraft-mp.com")) {
  46. writer.println(link.text());
  47. System.out.println(link.text());
  48. }
  49. }
  50. } catch (IOException e) {
  51. e.printStackTrace();
  52. }
  53. }
  54.  
  55. public static void main(String[] args) {
  56. new MMPExus();
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment