我有一个网址:
http://www.indeed.com/viewjob?jk=daddefef363643d7&qd=E8dXiB4h7yBMgEwoEDfyDF2ACaqK5NNcKe-lg0a0QeWlgGT7hwsgagao8YFkybxtaLZJqFprtIWhTxIjvWFBLUePVQb0Chqftd-uc7_Pfa4LB2pHYt-YP2NYagtBg9Lp&atk=1a4sk4spi1c0o5la&utm_source=publisher&utm_medium=organic_listings&utm_campaign=affiliate
我想为视图提取锚的href值并应用
我的代码是: -
$dom = new DOMDocument();
@$dom->loadHtml($html);
$xpath = new DOMXpath($dom);
$applylink = $xpath->query("//*[@class='job-footer-button-row']/a");
if(!is_null($applylink)){
$this->view->applylink = $applylink->item(0)->getAttribute('href');
}
但它始终显示以下错误:
Fatal error: Call to a member function getAttribute() on a non-object