下面是我的字符串
</div>
<div class="centered">Thanks for visiting</div>
<div id="related-videos">
<div class="generic-video-item">
<div class="thumb"><img src="http://watsite.yt/thumbnail.php?id=648p14jpgkgj" alt="" class="bg-image" /><span class="border"></span><span class="now-playing"></span><span class="video-subbed">subbed</span> <img src="http://static.cdn.animeultima.tv/images/star-trusted.png" alt="Trusted uploader" title="Trusted uploader" class="trusted" /></div>
watsite video by <a href="/users/Argro/">Argro</a><br /><span class="time">1 hour ago</span>
</div>
<div class="generic-video-item">
<div class="thumb"><a rel="nofollow" href="/Seitokai-Yakuindomo-2-episode-7-english-subbed-video-mirror-725129-watsite/"><img src="http://watsite.yt/thumbnail.php?id=4055g2gpbt2i" alt="" class="bg-image" /><span class="border"></span><span class="play"></span><span class="video-subbed">subbed</span> <img src="http://static.cdn.animeultima.tv/images/star-trusted.png" alt="Trusted uploader" title="Trusted uploader" class="trusted" /></a></div>
watsite video by <a href="/users/Argro/">Argro</a><br /><span class="time">1 hour ago</span>
</div>
<div class="generic-video-item">
<div class="thumb"><a rel="nofollow" href="/Seitokai-Yakuindomo-2-episode-7-english-subbed-video-mirror-725130-FLVUpload/"><img src="http://www.ragnaultima.com/mp4up.php?id=c56vy8likuy8" alt="" class="bg-image" /><span class="border"></span><span class="play"></span><span class="video-subbed">subbed</span> <img src="http://static.cdn.animeultima.tv/images/star-trusted.png" alt="Trusted uploader" title="Trusted uploader" class="trusted" /></a></div>
FLVUpload video by <a href="/users/Argro/">Argro</a><br /><span class="time">1 hour ago</span>
</div>
<div class="clear"></div>
</div>
<div class="centered">
<script language="JavaScript" type="text/javascript">
我正在尝试删除此网址
/Seitokai-Yakuindomo-2-episode-7-english-subbed-video-mirror-725130-FLVUpload/
目前我正在使用以下
$url = inbtwn($newData,'rel="nofollow" href="','-FLVUpload/">');
function inbtwn($input, $startcut, $finishcut){
$a1 = split($startcut, $input);
$a2 = split($finishcut, $a1[1]);
$output = $a2[0];
return $output;
}
但是它返回了我与watsite的结果,我如何从上面的字符串块中获得/ Seitokai-Yakuindomo-2-episode-7-english-subbed-video-mirror-725130-FLVUpload /。
感谢您的帮助
答案 0 :(得分:2)
parse_url()对您有用。
$url ='http://google.com/wrwetfrtgertger/';
$tmp = parse_url($url);
echo $tmp['path'];
或者代码不起作用。
$url ='http://google.com/wrwetfrtgertger/';
$tmp = parse_url($url);
echo $url = str_replace('http://'.$tmp['host'] ,'',$url);
答案 1 :(得分:1)
尝试使用正则表达式快速而肮脏
$regex = '/href\\s*=\\s*"([^"]*-FLVUpload\/)/s';
if (preg_match_all($regex, $newData, $matches_out)) {
$url = $matches_out[1][0];
print($url);
} else {
print('URL not found');
}