Java HTML Jsoup Document getIcon(Document doc)

Here you can find the source of getIcon(Document doc)

Description

get Icon

License

Open Source License

Declaration

public static String getIcon(Document doc) throws URISyntaxException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import org.jsoup.nodes.Document;

import java.net.URI;
import java.net.URISyntaxException;

public class Main {
    public static String getIcon(Document doc) throws URISyntaxException {
        String meta;/*from   w  w  w.j a va 2  s.  c  om*/
        try {
            meta = doc.head().select("link[href~=.*\\.ico]").first().attr("abs:href");
        } catch (NullPointerException ignored) {
            String uri = new URI(doc.location()).getHost();
            return uri.endsWith("/") ? uri + "favicon.ico" : uri + "/favicon.ico";
        }
        return meta;
    }
}

Related

  1. getDivForClass(Document document, String className)
  2. getDocument(CloseableHttpClient client, String url)
  3. getDocument(final String url)
  4. getDocument(String url)
  5. getHtmlDocument(String url)
  6. getInfoboxLines(final Document html, final boolean stripColor)
  7. getJSoupHtmlDocument(final String url)
  8. getJSoupXmlDocument(final String url)
  9. getLoginFields(Document doc)