Sometime the html meta like:
or or
If you just use “meta[name='keywords']” to find the node,you will get nothing.
Because what the phpquery do is expand css selector to xpath query.
Xpath require attribut value is case-sensitive. So where is the safe way to got [meta keywords]‘s attribute value?
$doc = phpQuery::newDocument($ff);
//open the phpquery debug mode
phpQuery::$debug = true;
$meta_val = '';
$g_select = 'meta[name]';
foreach($doc[$g_select] as $eml){
$name_tmp = pq($eml)->attr('name');
//force all meta name to be lowercase
pq($eml)->attr('name',strtolower($name_tmp));
}
$ff = $doc->htmlOuter();
phpQuery::unloadDocuments();
$doc = phpQuery::newDocumentHTML($ff);
//than we just use meta[name="keywords"] to got meta
$select = 'meta[name="keywords"]';
$meta = $doc['$select']