And*_*dré 4 php tags title phpquery
我是phpQuery的新手.我需要完成获取网页HTML TITLE标记内容的简单任务.在这种情况下,我试图获得"雅虎"的标题内容 应该是"雅虎".
我正在用phpQuery做这个,但它现在正在工作
// Testing phpQuery
$result = phpQuery::newDocumentFile($scraps['Scrap_yahoo']->getPage('http://www.yahoo.com','','off'))
->find('title');
echo $result->text();
Run Code Online (Sandbox Code Playgroud)
有人能给我一个如何实现这一目标的线索吗?
最好的祝福,
我认为问题可能是你的phpQuery调用::newDocumentFile().此函数需要一个文件名(不确定URL是否有效),但我怀疑你->getPage()实际上已经提取了该文件.如果是这样,那么使用正常::newDocument()如下:
$html = file_get_contents("http://www.yahoo.com/");
$pq = phpQuery::newDocument($html);
print $pq->find("title")->text();
Run Code Online (Sandbox Code Playgroud)
适合我.