我用的代码是:preg_match("/<head>(.*)<\/head>/i",$content, $matches);
匹配不到任何内容而用
eregi("<head>(.*)</head>",$content, $matches);
则能抓到<head></head>之间的内容谁能给出preg_match抓取<head></head>之间的内容的正则。
匹配不到任何内容而用
eregi("<head>(.*)</head>",$content, $matches);
则能抓到<head></head>之间的内容谁能给出preg_match抓取<head></head>之间的内容的正则。
能说具体点吗?
preg_match("/<head>(.*)<\/head>/mi",$content, $matches);
是这样吗?经测试还是不行啊。
require_once("snoopy.class.php");
$snoopy = new Snoopy;
$url="http://www.sina.com.cn";
$snoopy->fetch($url);
$content = $snoopy->results;
preg_match("/<head>(.*)<\/head>/i",$content, $matches);
print_r($matches);总是抓不到东西,页面光光的,查看原码也是空的。
$snoopy = new Snoopy;
$url="http://www.sina.com.cn";
$snoopy->fetch($url);
$content = $snoopy->results;
preg_match("/<head>(.*?)<\/head>/is",$content, $matches);//这样应该可以了
print_r($matches);
能讲一下为什么吗
为什么/i和/isu不行,而/is却可以呢
感谢 amani11 同学