Home >Backend Development >PHP Tutorial >有关PHP正则,提取网页指定内容的问题。

有关PHP正则,提取网页指定内容的问题。

WBOY
WBOYOriginal
2016-06-23 14:28:40926browse

php 正则

有关PHP正则,提取网页指定内容的问题。

源码:

E7%9B%92%E4%BD%BF%E7%94%A8%E6on%95%99%E7%A8%8B.mp4">

请问怎么把content=后面的链接地址提取出来?

回复讨论(解决方案)

求教!!

	$content = '<META name="httpfileurl" content=" http://stor.vdisk.cn/loadfile/C8/CE8%B5%84%E6%BA%90%E7%9B%92%E4%BD%BF%E7%94%A8%E6on%95%99%E7%A8%8B.mp4">';		$content = preg_match("|content=\"(.*)\"|",$content,$match);	echo($match[1]);

	$content = '<META name="httpfileurl" content=" http://stor.vdisk.cn/loadfile/C8/CE8%B5%84%E6%BA%90%E7%9B%92%E4%BD%BF%E7%94%A8%E6on%95%99%E7%A8%8B.mp4">';		$content = preg_match("|content=\"(.*)\"|",$content,$match);	echo($match[1]);


您好,非常感谢,这段代码可以用,我想知道,如果有多个content

我只想取"httpfileurl" content=" 后面的这个内容,该怎么办

	$content = '<META name="httpfileurl" content=" http://stor.vdisk.cn/loadfile/C8/CE8%B5%84%E6%BA%90%E7%9B%92%E4%BD%BF%E7%94%A8%E6on%95%99%E7%A8%8B.mp4">';		$content = preg_match("|content=\"(.*)\"|",$content,$match);	echo($match[1]);


代码是这样子的

 


	$content = '<META name="httpfileurl" content=" http://stor.vdisk.cn/loadfile/C8/CE8%B5%84%E6%BA%90%E7%9B%92%E4%BD%BF%E7%94%A8%E6on%95%99%E7%A8%8B.mp4">';		$content = preg_match("|content=\"(.*)\"|",$content,$match);	echo($match[1]);


代码是这样子的

 



$content = preg_match("|\"httpfileurl\"(\s+)?content=\"(.*)\"|",$content,$match);echo $match[2];

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn