mic*_*ele 6 php regex url image html-parsing
如何使用php从此链接中提取帖子图像?
我读到我不能用正则表达式做到这一点。
非常感谢。
$content=file_get_contents($url);
if (preg_match("/<img.*src=\"(.*)\".*class=\".*pinit\".*>/", $content, $matches))
{
echo "Match was found <br />";
echo $matches[0];
}
Run Code Online (Sandbox Code Playgroud)
$matches[0] 将打印整个图像标签。如果你只想提取 URL,那么你可以使用 $matches[1] 来获取相同的:)
| 归档时间: |
|
| 查看次数: |
5314 次 |
| 最近记录: |