脚本宝典收集整理的这篇文章主要介绍了使用PHP从URL中获取“property og”元标记,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
有没有办法使用PHP获取这些标签的内容,但没有AJAX或其他自定义解析器?起点是:
<?PHP $url = $_POST['link']; ?>
libXMl_use_internal_errors(true); $c = file_get_contents("http://url/here"); $d = new DomDocument(); $d->loadhtml($c); $xp = new domxpath($d); foreach ($xp->query("//Meta[@PRoPErty='og:title']") as $el) { echo $el->getAttribute("content"); } foreach ($xp->query("//Meta[@property='og:description']") as $el) { echo $el->getAttribute("content"); }
以上是脚本宝典为你收集整理的使用PHP从URL中获取“property og”元标记全部内容,希望文章能够帮你解决使用PHP从URL中获取“property og”元标记所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。