Search in sources :

Example 1 with DomElement

use of com.gargoylesoftware.htmlunit.html.DomElement in project azure-tools-for-java by Microsoft.

the class YarnHistoryTask method call.

@Override
public String call() throws Exception {
    WEB_CLIENT.setCredentialsProvider(credentialsProvider);
    HtmlPage htmlPage = WEB_CLIENT.getPage(path);
    // parse pre tag from html response
    // there's only one 'pre' in response
    DomNodeList<DomElement> preTagElements = htmlPage.getElementsByTagName("pre");
    if (preTagElements.size() == 0) {
        throw new HDIException("No logs here or logs not available");
    } else {
        return preTagElements.get(0).asText();
    }
}
Also used : DomElement(com.gargoylesoftware.htmlunit.html.DomElement) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HDIException(com.microsoft.azure.hdinsight.sdk.common.HDIException)

Example 2 with DomElement

use of com.gargoylesoftware.htmlunit.html.DomElement in project chuidiang-ejemplos by chuidiang.

the class ExtractingLinksWithHtmlUnit method main.

public static void main(String[] args) throws Exception {
    WebClient webClient = new WebClient();
    HtmlPage page = webClient.getPage("http://www.gnu.org/home.es.html");
    DomNodeList<DomElement> nodeList = page.getElementsByTagName("a");
    for (DomElement element : nodeList) {
        System.out.println(element.getTextContent() + " -> " + element.getAttribute("href"));
    }
}
Also used : DomElement(com.gargoylesoftware.htmlunit.html.DomElement) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) WebClient(com.gargoylesoftware.htmlunit.WebClient)

Aggregations

DomElement (com.gargoylesoftware.htmlunit.html.DomElement)2 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)2 WebClient (com.gargoylesoftware.htmlunit.WebClient)1 HDIException (com.microsoft.azure.hdinsight.sdk.common.HDIException)1