get favicon from html (JSOUP)

android, java, jsoup

Solution

Get the file name on head element:

Connection con2=Jsoup.connect(url);
Document doc = con2.get();
Element e=doc.head().select("link[href~=.*\\.ico]").first();
String url=e.attr("href");

http://jsoup.org/cookbook/extracting-data/attributes-text-html

http://jsoup.org/cookbook/extracting-data/selector-syntax

Problem

How can I get icon path from html string uses JSOUP? I find to diferent way to add favicon on webpage - (in Google) first method I can to get uses doc.select("html head meta") but I can't to select link tag

Original source