Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php get site metat tags

function getSiteOG( $url, $specificTags=0 ){
  $doc = new DOMDocument();
  @$doc->loadHTML(file_get_contents($url));
  $res['title'] = $doc->getElementsByTagName('title')->item(0)->nodeValue;

  foreach ($doc->getElementsByTagName('meta') as $m){
      $tag = $m->getAttribute('name') ?: $m->getAttribute('property');
      if(in_array($tag,['description','keywords']) || strpos($tag,'og:')===0) $res[str_replace('og:','',$tag)] = $m->getAttribute('content');
  }
  return $specificTags? array_intersect_key( $res, array_flip($specificTags) ) : $res;
}
Comment

PREVIOUS NEXT
Code Example
Php :: random String Function PHP 
Php :: update php version cpanel 
Php :: laravel query 
Php :: read file and convert each line in array php 
Php :: how to store array in variable php 
Php :: php nested array 
Php :: how to pass value from one php page to another using session 
Php :: random number php 
Php :: image::make en php 
Php :: image not displaying in laravel 
Php :: str_word_count() 
Php :: select query into left join doctrine 
Php :: addphp calculate next letter 
Java :: minecraft death counter 
Java :: import java math 
Java :: java swing make window not resizable 
Java :: java print stack trace to string 
Java :: junit 5 dependency maven 
Java :: textview set drawable right programmatically 
Java :: how to circular a bitmap android 
Java :: statement delete sql java 
Java :: toast java example 
Java :: java count files in folder 
Java :: how to print a matrix in java 
Java :: java timestamp 
Java :: java measure execution time 
Java :: Java get fps 
Java :: flutter request location permission 
Java :: how can i to do java home 
Java :: how to print elements in matrix java 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =