因此,我正在使用php file_get_contents("".$result['href'][0]."");
获取链接内容,并使用preg_match(“ /\(.*)\ / i”,$ str,$ title获取网站的标题); `。因此,我现在要做的就是获取favicon href值,以获取用户给出的搜索链接的图像。任何帮助将不胜感激。
以下是获取网站标题的代码:
$str = file_get_contents("".$result['href'][0]."");
$str = trim(preg_replace('/\s+/', ' ', $str));
preg_match("/\<title\>(.*)\<\/title\>/i",$str,$title);
如果有不清楚的地方,请告诉我。谢谢。