Mình sử dụng file_get_html('url web') để lấy toàn bộ nội dung của website, nhưng mình không biết cách lấy thẻ title và description, keyword meta như thế nào hết. Bạn nào biết cách lấy title, meta description và meta keyword sử dụng PHP Simple HTML DOM Parser không giúp mình với nhé. Ví dụ mình lấy : $html = file_get_html('https://itseovn.com'); Thì làm sao để lấy được thẻ meta description, title, keyword được ở web itseovn mình mới lấy kia được, Cảm ơn
Để lấy thẻ title: Mã: require_once "simple_html_dom.php"; // Chèn thư viện simple_html_dom tách lấy html $link='https://itseovn.com'; //đường dẫn web cần lấy tin $html=file_get_html($link); // html chưa toan bộ nội dung copy trên web //Lấy Title web foreach($html->find('title') as $element) { $title= trim($element->plaintext); // Chỉ lấy phần text } //Lấy thẻ meta description $Description = $html->find("meta[name='description']", 0)->content; //Lấy thẻ meta keyword $Description = $html->find("meta[name='keywords']", 0)->content; //lấy nội dung thẻ div bất kỳ foreach($html->find('#divname') as $element) // .divname or #divname or .divname h1 or #divname .divnone { $ContentDiv = trim($element->plaintext); // Chỉ lấy phần text } Download thư viện ở đây: http://simplehtmldom.sourceforge.net/