Search in sources :

Example 6 with MetaInfo

use of org.loboevolution.info.MetaInfo in project LoboEvolution by LoboEvolution.

the class HtmlContent method getJSList.

/**
 * <p>getJSList.</p>
 *
 * @return a {@link java.util.List} object.
 */
public List<MetaInfo> getJSList() {
    final List<MetaInfo> infoList = new ArrayList<>();
    final HTMLDocumentImpl doc = (HTMLDocumentImpl) this.document;
    final HTMLCollectionImpl nodeList = (HTMLCollectionImpl) doc.getElementsByTagName("script");
    if (nodeList == null) {
        return null;
    }
    nodeList.forEach(node -> {
        if (node instanceof HTMLElement) {
            final HTMLElement element = (HTMLElement) node;
            String src = element.getAttribute("src");
            if (Strings.isNotBlank(src)) {
                if (!Urls.isAbsolute(src)) {
                    src = doc.getFullURL(src).toString();
                }
                if (src.startsWith("//")) {
                    src = "http:" + src;
                }
                infoList.add(MetaInfo.builder().name(src).build());
            }
        }
    });
    return infoList;
}
Also used : HTMLDocumentImpl(org.loboevolution.html.dom.domimpl.HTMLDocumentImpl) HTMLElement(org.loboevolution.html.dom.HTMLElement) MetaInfo(org.loboevolution.info.MetaInfo) ArrayList(java.util.ArrayList) HTMLCollectionImpl(org.loboevolution.html.dom.domimpl.HTMLCollectionImpl)

Example 7 with MetaInfo

use of org.loboevolution.info.MetaInfo in project LoboEvolution by LoboEvolution.

the class HtmlContent method getMetaList.

/**
 * <p>getMetaList.</p>
 *
 * @return a {@link java.util.List} object.
 */
public List<MetaInfo> getMetaList() {
    final List<MetaInfo> infoList = new ArrayList<>();
    final HTMLDocumentImpl doc = (HTMLDocumentImpl) this.document;
    final HTMLCollectionImpl nodeList = (HTMLCollectionImpl) doc.getElementsByTagName("meta");
    if (nodeList == null) {
        return null;
    }
    nodeList.forEach(node -> {
        if (node instanceof HTMLElement) {
            final HTMLElement element = (HTMLElement) node;
            infoList.add(MetaInfo.builder().name(element.getAttribute("name")).itemprop(element.getAttribute("itemprop")).property(element.getAttribute("property")).httpEqui(element.getAttribute("http-equi")).content(element.getAttribute("content")).description(element.getAttribute("description")).charset(element.getAttribute("charset")).build());
        }
    });
    return infoList;
}
Also used : HTMLDocumentImpl(org.loboevolution.html.dom.domimpl.HTMLDocumentImpl) HTMLElement(org.loboevolution.html.dom.HTMLElement) MetaInfo(org.loboevolution.info.MetaInfo) ArrayList(java.util.ArrayList) HTMLCollectionImpl(org.loboevolution.html.dom.domimpl.HTMLCollectionImpl)

Aggregations

ArrayList (java.util.ArrayList)7 MetaInfo (org.loboevolution.info.MetaInfo)7 HTMLElement (org.loboevolution.html.dom.HTMLElement)4 HTMLCollectionImpl (org.loboevolution.html.dom.domimpl.HTMLCollectionImpl)4 HTMLDocumentImpl (org.loboevolution.html.dom.domimpl.HTMLDocumentImpl)4 DefaultTableModel (javax.swing.table.DefaultTableModel)3 RSyntaxTextArea (org.fife.ui.rsyntaxtextarea.RSyntaxTextArea)1 HTMLImageElementImpl (org.loboevolution.html.dom.domimpl.HTMLImageElementImpl)1 TimingInfo (org.loboevolution.info.TimingInfo)1