Search in sources :

Example 1 with DetailModel

use of com.fiction.y.detail.m.DetailModel in project AndroidDevelop by 7449.

the class JsoupTool method getDetail.

public DetailModel getDetail(String url) {
    Document document = getDocument(url);
    DetailModel detailModel = new DetailModel();
    if (document == null) {
        throw new NullPointerException("the document is null");
    }
    Elements select = document.select("div.bottem2").select("a[href$=.html]");
    for (int i = 0; i < select.size(); i++) {
        switch(i) {
            case 0:
                detailModel.setOnPage(select.get(i).attr("abs:href"));
                break;
            case 1:
                detailModel.setNextPage(select.get(i).attr("abs:href"));
                break;
        }
    }
    detailModel.setTitle(document.select("div.bookname").select("h1").text());
    detailModel.setContent(document.select("#content").html());
    KLog.i(detailModel.getOnPage() + "    " + detailModel.getNextPage());
    return detailModel;
}
Also used : DetailModel(com.fiction.y.detail.m.DetailModel) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements)

Aggregations

DetailModel (com.fiction.y.detail.m.DetailModel)1 Document (org.jsoup.nodes.Document)1 Elements (org.jsoup.select.Elements)1