summaryrefslogtreecommitdiff
path: root/src/main/java/files/Parser.java
blob: 486135b97721e4e2a68ebb0804213f908041010c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package files;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

import java.io.IOException;
import java.net.URL;

public class Parser {

    public static Document getPage() throws IOException {
        String url = "https://jut.su/anime/";
        return Jsoup.parse(new URL(url), 3000);
    }

    public static void main(String[] args) throws IOException {
        Element animeList = Parser.getPage().select("div[class=all_anime_content anime_some_margin]").first();
        assert animeList != null;
        Elements names = animeList.select("div[class=aaname]");

        for (Element name : names) {
            String text = name.toString();
            int start = 22;
            int end = text.indexOf("</div>") - 1;
            char[] dst = new char[end - start];
            text.getChars(start, end, dst, 0);
            System.out.println(dst);
        }
    }
}