[英]How to get the html title(header) with SimpleHTMLDom
我已經使用simple_html_dom在head標簽中獲得了頁面標題...我已經在尋找實現方案的解決方案...您能不能給我一些幫助呢。
謝謝..
手冊很清楚,無論如何您都可以使用以下代碼實現:
給定標簽<title>IANA — Example domains</title>
您可以使用的<title>IANA — Example domains</title>
include 'simple_html_dom.php';
$url = 'http://www.example.com';
$html = new simple_html_dom();
$html->load_file($url);
$title = $html->find('title',0);
echo $title->plaintext;
//output : IANA — Example domains
純文本將為您提供剝離所有html標記的內容,因此...純文本。 如果需要innerHtml,可以使用$title->innertext;
相反(在這種情況下,它沒有任何區別,但是如果您要獲取的標記中包含html標記,則會有所不同)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.