我正在尝试从 html 页面获取确切的域 url
我尝试这个 url 只从 v.html 返回
https://picasaweb.google.com/114948445121686813006/DropBox?authkey=Gv1sRgCMLjxpef1rHJ3QE#5929911272604125650
但我的 php 函数显示所有网址
v.html 有html代码和链接
这是我的 php 代码
<?php
$string=file_get_contents("v.html");
function getUrls($string)
{
$regex = '/https?\:\/\/[^\" ]+/i';
preg_match_all($regex, $string, $matches);
return ($matches[0]);
}
$urls = getUrls($string);
foreach($urls as $url)
{
echo $url.'<br />';
}
?>
输出
http://www.w3.org/2007/app
http://schemas.google.com/photos/2007
http://www.w3.org/2005/Atom
http://purl.org/atom/app#
http://www.w3.org/2007/app
http://schemas.google.com/photos/2007
http://www.w3.org/2005/Atom
http://purl.org/atom/app#
http://www.w3.org/2007/app
http://www.w3.org/2005/Atom
http://purl.org/atom/app#
http://www.w3.org/2007/app
https://picasaweb.google.com/114948445121686813006/DropBox?authkey=Gv1sRgCMLjxpef1rHJ3QE#5929911272604125650