Search in sources :

Example 41 with Elements

use of org.jsoup.select.Elements in project Asqatasun by Asqatasun.

the class Aw22Rule05081 method extractTableWithDataTableMarkup.

/**
     * 
     * @param sspHandler
     * @param elementHandler 
     * @param elementHandlerWithoutDataTableMarkup
     */
private void extractTableWithDataTableMarkup(ElementHandler<Element> elementHandler, ElementHandler<Element> elementHandlerWithoutDataTableMarkup) {
    Elements elementsWithMarkup = new Elements();
    for (Element el : elementHandler.get()) {
        if (el.select(DATA_TABLE_MARKUP_CSS_LIKE_QUERY).size() > 0) {
            elementsWithMarkup.add(el);
        } else if (elementHandlerWithoutDataTableMarkup != null) {
            elementHandlerWithoutDataTableMarkup.add(el);
        }
    }
    elementHandler.clean().addAll(elementsWithMarkup);
}
Also used : Element(org.jsoup.nodes.Element) Elements(org.jsoup.select.Elements)

Example 42 with Elements

use of org.jsoup.select.Elements in project Asqatasun by Asqatasun.

the class PathElementBuilderTest method testBuildTextFromElement.

/**
     * Test of buildTextFromElement method, of class PathElementBuilder.
     */
public void testBuildTextFromElement() throws IOException {
    LOGGER.info("buildTextFromElement");
    Document document = Jsoup.parse(FileUtils.readFileToString(new File("src/test/resources/pathBuilder/test1.html")));
    Element el = document.select("footer").first();
    PathElementBuilder instance = new PathElementBuilder(true);
    String result = instance.buildTextFromElement(el);
    LOGGER.debug("result = " + result);
    Elements elementsFromBuiltPath = document.select(result);
    assertEquals(1, elementsFromBuiltPath.size());
    assertEquals(el, elementsFromBuiltPath.first());
}
Also used : Element(org.jsoup.nodes.Element) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements) File(java.io.File)

Example 43 with Elements

use of org.jsoup.select.Elements in project Asqatasun by Asqatasun.

the class Rgaa30Rule050501 method select.

@Override
protected void select(SSPHandler sspHandler) {
    super.select(sspHandler);
    // once tables selected, we extract the caption child element of each 
    // to make the control
    Elements captionOnTable = new Elements();
    for (Element el : getSelectionWithoutMarkerHandler().get()) {
        captionOnTable.add(el.select(CAPTION_ELEMENT).first());
    }
    getSelectionWithoutMarkerHandler().clean().addAll(captionOnTable);
    Elements captionOnDataTable = new Elements();
    for (Element el : getSelectionWithMarkerHandler().get()) {
        captionOnDataTable.add(el.select(CAPTION_ELEMENT).first());
    }
    getSelectionWithMarkerHandler().clean().addAll(captionOnDataTable);
}
Also used : Element(org.jsoup.nodes.Element) Elements(org.jsoup.select.Elements)

Example 44 with Elements

use of org.jsoup.select.Elements in project Asqatasun by Asqatasun.

the class Rgaa32016Rule050201 method select.

@Override
protected void select(SSPHandler sspHandler) {
    super.select(sspHandler);
    // once tables selected, we extract the caption child element of each 
    // to make the control
    Elements captionOnTable = new Elements();
    for (Element el : getSelectionWithoutMarkerHandler().get()) {
        captionOnTable.add(el.select(CAPTION_ELEMENT).first());
    }
    getSelectionWithoutMarkerHandler().clean().addAll(captionOnTable);
    Elements captionOnDataTable = new Elements();
    for (Element el : getSelectionWithMarkerHandler().get()) {
        captionOnDataTable.add(el.select(CAPTION_ELEMENT).first());
    }
    getSelectionWithMarkerHandler().clean().addAll(captionOnDataTable);
}
Also used : Element(org.jsoup.nodes.Element) Elements(org.jsoup.select.Elements)

Example 45 with Elements

use of org.jsoup.select.Elements 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

Elements (org.jsoup.select.Elements)218 Element (org.jsoup.nodes.Element)120 Document (org.jsoup.nodes.Document)78 Test (org.junit.Test)60 ArrayList (java.util.ArrayList)51 Configuration (com.vaadin.addon.charts.model.Configuration)27 IOException (java.io.IOException)26 URL (java.net.URL)13 ParseTest (org.jsoup.integration.ParseTest)11 File (java.io.File)9 List (java.util.List)9 HashMap (java.util.HashMap)7 SSPHandler (org.asqatasun.processor.SSPHandler)7 TestSolutionHandler (org.asqatasun.ruleimplementation.TestSolutionHandler)7 ProcessRemarkService (org.asqatasun.service.ProcessRemarkService)7 MalformedURLException (java.net.MalformedURLException)6 Logger (org.slf4j.Logger)6 LoggerFactory (org.slf4j.LoggerFactory)6 PlotOptionsLine (com.vaadin.addon.charts.model.PlotOptionsLine)5 RequestUtil (com.kyj.fx.voeditor.visual.util.RequestUtil)4