Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.awsomeman.exus.mmp;
- import java.io.File;
- import java.io.IOException;
- import java.io.PrintWriter;
- import org.jsoup.Jsoup;
- import org.jsoup.nodes.Document;
- import org.jsoup.nodes.Element;
- import org.jsoup.select.Elements;
- public class MMPExus {
- private File ipFile;
- private PrintWriter writer;
- public MMPExus() {
- int page = 0;
- ipFile = new File("C:/Users/Aaron/Documents/Research/mmp_ips.txt");
- try {
- writer = new PrintWriter(ipFile);
- writer.write("The list of ips:\n");
- // Needs to be updated as more servers are added.
- while(page <= 649) {
- page++;
- collectPageData(page);
- }
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- writer.close();
- }
- }
- public void collectPageData(int page) {
- try {
- Document doc = Jsoup.connect("http://minecraft-mp.com/servers/list/" + page + "/").userAgent("Mozilla").get();
- Elements serverIp = doc.select("strong");
- for (Element link : serverIp) {
- /*
- * Data is stored in <strong> tags but so is the rank number
- * and the site name. This filters the data so we just have
- * the ip.
- */
- if(!link.toString().contains("#") && !link.toString().contains("Minecraft-mp.com")) {
- writer.println(link.text());
- System.out.println(link.text());
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public static void main(String[] args) {
- new MMPExus();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment