html链接是:
<a title="Next page of results" class="sprBtnSRP1 enabled" href="http://www.link.com/page.html?thisisthelink&_pgn=2&_al=25&at=tc"><i>Next</i><b class="sprBtnSRP1"></b></a>
php是:
function NextLink($url){
$html= WGET($url);
$urlpattern1 = '/Next"><a[^>]+pgn=([^"]+)/i';
preg_match_all($urlpattern1, $html, $matches1);
$nextlink='http://www.link.com/page.html?thisisthelink&_pgn=';
foreach ($matches1[1] as $u) {
$nextlink = $nextlink.$u;
}
return $nextlink;
}
不再工作了,我需要的是PHP $ nexlink。$ u成为http://www.link.com/page.html?thisisthelink&_pgn=2&_al=25&at=tc
问题是$ urlpattern1
提前感谢您的帮助!
答案 0 :(得分:0)
尝试这种模式:
$urlpattern1 = '/<a\s+.*?href=".*?_pgn=(.*?)".*?>/i';
修改:
如果只有您想要的链接,那么您可以使用标题(或其他参数)作为提示,请尝试以下模式:
$urlpattern1 = '/<a\s+.*?title="Next page of results"\s+.*?href=".*?\_pgn=(.*?)".*?>/i';