Get_meta_tags help

software development

#1

Iam using get_meta_tags And dont works .
with curl I access to the web

$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $web);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
$lines = array();
$lines = explode("\n", $ch);

// display file line by line
foreach($lines as $line_num => $line) {
$html .= htmlspecialchars($line); }

I like to take de metatags with preg_match.
Can Help me?


#2

I wrote my own version using regular expressions taken from the PHP documentation:

<?php $web = "http://dreamhost.com/"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $web); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5); $file_contents = curl_exec($ch); curl_close($ch); preg_match_all("|<meta[^>]+name=\"([^\"]*)\"[^>]" . "+content=\"([^\"]*)\"[^>]+>|i", $file_contents, $tags, PREG_PATTERN_ORDER); echo "<pre>"; print_r($tags); echo "</pre>"; ?>It works just fine: [example]

si-blog
Max discount on any plan with promocode SCJESSEYTOTAL