How can I extract a page's title
and meta description
using the PHP Simple HTML DOM Parser?
I just need the title of the page and the keywords in plain text.
$html->find('meta[name=keywords]',0)->attr['content'];
$html->find('meta[name=description]',0)->attr['content'];
$html = new simple_html_dom();
$html->load_file('some_url');
//To get Meta Title
$meta_title = $html->find("meta[name='title']", 0)->content;
//To get Meta Description
$meta_description = $html->find("meta[name='description']", 0)->content;
//To get Meta Keywords
$meta_keywords = $html->find("meta[name='keywords']", 0)->content;
NOTE: The names of meta tags are casesensitive!
you can using php code and so simple to know. like here
$result = 'site.com'; $tags = get_meta_tags("html/".$result);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With