我将建议使用get_meta_tags(),但似乎不起作用(对我而言):s
<?php$tags = get_meta_tags('http://www.example.com/');echo $tags['og:image'];?>但是我还是建议还是使用DOMdocument:
<?php$sites_html = file_get_contents('http://example.com');$html = new DOMdocument();@$html->loadHTML($sites_html);$meta_og_img = null;//Get all meta tags and loop through them.foreach($html->getElementsByTagName('meta') as $meta) { //If the property attribute of the meta tag is og:image if($meta->getAttribute('property')=='og:image'){ //Assign the value from content attribute to $meta_og_img $meta_og_img = $meta->getAttribute('content'); }}echo $meta_og_img;?>希望能帮助到你



