ankur0101 Posted October 13, 2009 Share Posted October 13, 2009 Hello everybody I want to fetch meta tags of a domain. It will be done from following code of index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <style type="text/css"> <!-- .style1 { font-size: 24px } --> </style> </head> <body> <p> </p> <p> </p> <p> </p> <form id="form1" name="form1" method="post" action="index.php"> <div align="center" class="style1">Enter Domain Name : <label> <input name="domain" type="text" id="domain" value="http://www.google.com" size="35" /> </label> <label> <input type="submit" name="submit" id="submit" value="search" /> </label> </div> </form> <p align="center">E.g. google.com</p> </body> </html> Here is the code for domains.php <?php $domain = "series99.com"; $tags = get_meta_tags("http://".$domain); Website Description : <?php echo $tags['description']; ?> ?> I am able to fetch Description and keywords. But problems are 1) How to fetch title ? 2) What I want to do is when a person will enter domain name on index.php, he will get redirected to domains.php but it will be something like domain.php?domain=series99.com Then the domains.pgp page will show the data of series99.com. Temporarily I have kept $domain = ""series99.com"; How can I replace it by the domain name written by a person on index.php ??? Thanks Link to comment https://forums.phpfreaks.com/topic/177565-fetching-meta-tags-through/ Share on other sites More sharing options...
ankur0101 Posted October 14, 2009 Author Share Posted October 14, 2009 Hello, is anybody here ? Link to comment https://forums.phpfreaks.com/topic/177565-fetching-meta-tags-through/#findComment-936709 Share on other sites More sharing options...
cags Posted October 14, 2009 Share Posted October 14, 2009 You would have to open the file and search for the <title> tag. Regular Expressions (preg_match) would be your best bet... at it's simplest form you could use something like... ~<title>(.+?)</title>~ Link to comment https://forums.phpfreaks.com/topic/177565-fetching-meta-tags-through/#findComment-936775 Share on other sites More sharing options...
knsito Posted October 14, 2009 Share Posted October 14, 2009 cool.. DOMDocument class http://us3.php.net/manual/en/class.domdocument.php This class looks quite useful, maybe overkill just to get the page title but works.. Not my code: function get_remotetitle($urlpage){ $dom = new DOMDocument(); if(@$dom->loadHTMLFile($urlpage)) { //use @:suppress warnings $list = $dom->getElementsByTagName("title"); if ($list->length > 0) { return $list->item(0)->nodeValue; } } return false; } Link to comment https://forums.phpfreaks.com/topic/177565-fetching-meta-tags-through/#findComment-936928 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.