mercredi 21 octobre 2020

I would like to retrieve the icon of a site

I'm making a little software that allows me to retrieve some information from a site, and I can't retrieve the site's icon. I already made this code to recover the title:

private String getWebSiteTitle(URL url) throws IOException {
    HTMLEditorKit htmlKit = new HTMLEditorKit();
    HTMLDocument htmlDoc = (HTMLDocument) htmlKit.createDefaultDocument();
    HTMLEditorKit.Parser parser = new ParserDelegator();
    parser.parse(new InputStreamReader(url.openStream()),
            htmlDoc.getReader(0), true);

    return (String) htmlDoc.getProperty("title");
}

Aucun commentaire:

Enregistrer un commentaire