MDanz Posted October 28, 2009 Share Posted October 28, 2009 <?php $tags = get_meta_tags('http://www.realgm.com/'); echo $tags['keywords']; echo $tags['description']; ?> i just used any website.. i can't get the meta tags though... what am i doing wrong? i get these error messages.. Warning: get_meta_tags() [function.get-meta-tags]: URL file-access is disabled in the server configuration in /home/ustackc1/public_html/menu.php on line 78 Warning: get_meta_tags(http://www.realgm.com/) [function.get-meta-tags]: failed to open stream: no suitable wrapper could be found in /home/ustackc1/public_html/menu.php on line 78 Quote Link to comment https://forums.phpfreaks.com/topic/179413-php-get-meta-tags-help/ Share on other sites More sharing options...
DavidAM Posted October 28, 2009 Share Posted October 28, 2009 Did you read the error messages? URL file-access is disabled in the server configuration The PHP configuration on your server does not allow URL access for this (and several other file) functions. Quote Link to comment https://forums.phpfreaks.com/topic/179413-php-get-meta-tags-help/#findComment-946682 Share on other sites More sharing options...
MDanz Posted October 29, 2009 Author Share Posted October 29, 2009 is there another way i can get meta tags then? i been stuck on this for a week lol Quote Link to comment https://forums.phpfreaks.com/topic/179413-php-get-meta-tags-help/#findComment-946700 Share on other sites More sharing options...
DavidAM Posted October 29, 2009 Share Posted October 29, 2009 I don't know. But if your server provided has the URL file-access disabled, then you will probably have to use cURL (if that is enabled). I have never used it, in fact, never even looked at it, so maybe someone else can offer an idea. Sorry, Quote Link to comment https://forums.phpfreaks.com/topic/179413-php-get-meta-tags-help/#findComment-946723 Share on other sites More sharing options...
MadTechie Posted October 29, 2009 Share Posted October 29, 2009 try this, I have been a little lazy here with the RegEx's <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.realgm.com/"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $html = curl_exec($ch); curl_close($ch); $meta = array(); preg_match_all('/<meta[^>]*?name\s*=\s*(["\'])([^\1>]*?)\1[^>]*?content\s*=\s*(["\'])([^\3>]*?)\3/sim', $html, $result, PREG_SET_ORDER); foreach($result as $M){ $meta[$M[2]] =$M[4]; } preg_match_all('/<meta[^>]*?content\s*=\s*(["\'])([^\1>]*?)\1[^>]*?name\s*=\s*(["\'])([^\3>]*?)\3/sim', $html, $result, PREG_SET_ORDER); foreach($result as $M){ $meta[$M[2]] =$M[4]; } var_dump($meta); ?> Quote Link to comment https://forums.phpfreaks.com/topic/179413-php-get-meta-tags-help/#findComment-946741 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.