I am working on a Project in which the input is URL and the output is the website Logo. There are some websites like Facebook,Youtube, yahoo etc which uses CSS to make their logo attractive, So how can i fetch the logo of these websites. I have written the following code to fetch the logo of those websites which uses Logo image :
Elements elements = doc.getElementsByTag("img");
for (Element element : elements) {
//Searching the src tag inside img tag
logo =element.attr("src");
String logo1=logo;
//If src link has substring logo
if(logo1.toLowerCase().contains("logo")|| element.attr("alt").toLowerCase().contains("logo"))
{
if(!logo.contains("http"))
{
if(!logo.startsWith("/"))
logo=link + "/"+logo;
else
logo=link+logo;
}
System.out.println(logo);
logoflag=1;
}
}