我正在尝试从url中提取所有元属性。这是代码
function fetch_http_equiv($url)
{
$data = file_get_contents($url);
$dom = new DomDocument;
@$dom->loadHTML($data);
$xpath = new DOMXPath($dom);
$metas = $xpath->query('//*/meta[starts-with(@http-equiv)]');
$http_equiv = array();
foreach($metas as $meta){
$property = $meta->getAttribute('http-equiv');
$content = $meta->getAttribute('content');
$http_equiv[$property] = $content;
}
return $http_equiv;
}
// fetch meta http-equiv 's
$http_equiv = fetch_http_equiv($link);
// if $http_equiv Content-Language exists
if (empty($http_equiv['Content-Language'])) {
}else{
$meta_content_language = $http_equiv['Content-Language'];
}为了上帝的爱,在我的脑海里,它应该有效,我错过了什么?
编辑:我发现了一个问题,我确实改变了
$property = $meta->getAttribute('http_equiv');至
$property = $meta->getAttribute('http-equiv');案子解决了。
发布于 2018-09-16 11:23:08
我发现了一个问题,我确实改变了
$property = $meta->getAttribute('http_equiv');至
$property = $meta->getAttribute('http-equiv');案子解决了。
密码现在起作用了。
https://stackoverflow.com/questions/52352758
复制相似问题