我正在尝试使用 php 从 Instagram url 中抓取图像 url。图片网址似乎包含在页面顶部的元标记中,如下所示:
<meta property="og:image" content="http://distilleryimage10.ak.instagram.com/9e4360c6220411e38abf22000a1f9bf5_7.jpg" />
从这里我想返回内容部分,例如http://distilleryimage10.ak.instagram.com/9e4360c6220411e38abf22000a1f9bf5_7.jpg
我需要对多个图像执行此操作,因此即使 url 发生更改,我也需要提取此图像。
我到目前为止的代码是
$page = file_get_contents('http://instagram.com/p/efH-NVOTAy/#');
preg_match("/og:image/", $page, $matches);
print_r($matches);
这将打印 Array ( [0] => og:image )
只要它匹配'og:image'并确认它可以在从file_get_contents返回的数据中找到这个字符串,它就可以工作,但我不确定如何实现从这一行返回url的飞跃?