Advertisement
Guest User

Minecraft Server List Ip Collector

a guest
Mar 22nd, 2015
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. package com.awsome.exus.mso;
  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 MSOExus {
  13.  
  14. private File ipFile;
  15. private PrintWriter writer;
  16.  
  17. public MSOExus() {
  18. int page = 0;
  19. ipFile = new File("C:/Users/Aaron/Documents/Research/mso_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 <= 248) {
  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-server-list.com/page/" + page + "/").userAgent("Mozilla").get();
  38. Elements serverIp = doc.select("div.adressen.online");
  39. for (Element link : serverIp) {
  40. writer.println(link.text());
  41. System.out.println(link.text());
  42. }
  43. } catch (IOException e) {
  44. e.printStackTrace();
  45. }
  46. }
  47.  
  48. public static void main(String[] args) {
  49. new MSOExus();
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement