Some website source codes include 1linkrelw.cuticonhreffavicon. icotypeimagex-icon or 1linkreliconhreffavicon. icotypeimagex-icon to specify the icon location. However, most browsers support automatic retrieval.
Some website source codes include: 1 link rel = "shortcut icon" href = "/favicon. ico "type =" image/x-icon "/or 1 link rel =" icon "href ="/favicon. ico "type =" image/x-icon. However, most browsers support automatic retrieval.
YesWebsiteThese lines of code are added to the source code:
1
Or
1
You can specifyIconLocation storage.
However, most browsers currently support automaticObtainWebsite. Ico under the root directoryFileSo the lines of code cannot be seen in the source code.
Feasible Method:
1 // get every url,ObtainIcon 2 $ url = $ matches [1] [$ I]; 3 $ contents = @ file_get_contents ($ url); 4 preg_match ('/
/', $ Contents, $ icon); 5 if (! Empty ($ icon) {6 // print_r ($ icon [1]); 7 echo"
"; 8 $ array = @ get_headers ($ icon [1], 1); 9 if (preg_match ('/ 200/', $ array [0]) {10 // echo""; 11 print_r ($ icon [1]); 12 echo" $ icon [1]. "'>; 13 // echo" string "; 14 // print_r ($ array ); 15} else {16 // remove the redundant slash 17 $ url = substr_replace ($ url, "",-1); 18 echo "invalid url resource! ". $ Url. $ icon [1]; 19 echo "$ url. $ icon [1]. "'>; 20} 21 22} else {23 // here I tried many methods. Later I found that the url can be used to capture the root directory of the url, due to the habitualFileThe name is favicon. ico, so you can directly access a url like this to getIconFile, Http://wenwen.sogou.com/favicon.ico24 $ url = substr ($ url, 7); // remove the first 25 $ position = strpos ($ url, '/'); 26 $ url = substr ($ url, 0, $ position); 27 echo "$ url. "/favicon. ico '>; 28 // echo $ url. "/favicon. ico
"; 29 // judgmentWebsiteWhether the root directory of. icon existsFile30 // $ url = 'HTTP ://'. $ _ SERVER ['server _ name']. $ _ SERVER ["REQUEST_URI"]; 31 // echo dirname ($ url); 32 // if (file_exists ("favicon. ico ") 33 // echo"Exist
"; 34}
Ideas:
First, determine whether there are several lines of code added to iocn in the source code. If there is one, directly capture the code, then determine whether the code is a valid url, and then determine whether the code is displayed. If notObtainThe root directory is displayed.