谢谢大家,我知道了!
最终代码:
$html = file_get_contents('bookmarks.html');//Create a new DOM document$dom = new DOMdocument;//Parse the HTML. The @ is used to suppress any parsing errors//that will be thrown if the $html string isn't valid XHTML.@$dom->loadHTML($html);//Get all links. You could also use any other tag name here,//like 'img' or 'table', to extract other tags.$links = $dom->getElementsByTagName('a');//Iterate over the extracted links and display their URLsforeach ($links as $link){ //Extract and show the "href" attribute. echo $link->nodevalue; echo $link->getAttribute('href'), '<br>';}这将显示给您分配的 anchor 文本和 .html 文件中所有链接的 href 。 __
再次,非常感谢。



