如何使用php从此链接中提取帖子图像?
我读到我用正则表达式无法做到这一点。
http://www.huffingtonpost.it/2013/07/03/stupri-piazza-tahrir-durante-proteste-anti-morsi_n_3538921.html?utm_hp_ref=italy
非常感谢。
最佳答案
$content=file_get_contents($url);
if (preg_match("/<img.*src=\"(.*)\".*class=\".*pinit\".*>/", $content, $matches))
{
echo "Match was found <br />";
echo $matches[0];
}
$ matches [0]将打印整个图像标签。
而且,如果您只想提取URL,则可以使用$ matches [1]获得相同的结果:)
关于php - 使用php从html页面提取图像url。,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17445111/