php,preg_match匹配不成功,而用eregi可以匹配,什么原因? 20
$url="http://localhost/zhaopin.html";//目标站$fp=@fopen($url,"r")ordie("超时");$fcontents=...
$url = "http://localhost/zhaopin.html"; //目标站
$fp = @fopen($url, "r") or die("超时");
$fcontents = file_get_contents($url);
preg_match("/<div id=\"content\"><p class=\"MsoNormal\" style=\"margin: 0cm 0cm 0pt; text-indent: 44.15pt; line-height: 200%; text-align: center; mso-char-indent-count: 2.0\" align=\"center\"><strong style=\"mso-bidi-font-weight: normal\"><span style=\"font-size: 22pt; line-height: 200%; font-family: 宋体\">(.*)<p class=\"MsoNormal\" style=\"margin: 0cm 0cm 0pt; text-indent: 32pt; line-height: 200%; text-align: left; mso-char-indent-count: 2.0\" align=\"left\"><span lang=\"EN-US\" style=\"font-size: 16pt; line-height: 200%; font-family: 宋体\"><o:p> </o:p></span></p></div>
<div id=\"pageString\"></div>/", $fcontents, $regs);
//echo $regs;
//$regs[1]=str_replace("src=\"../images/","src=\"http://weather.tq121.com.cn/images/",$regs[1]);
$regs[1]=str_replace("<div id=\"title\">","<div align=\"center\">",$regs[1]);
$regs[1]=str_replace("<div id=\"time\">","<div align=\"center\">",$regs[1]);
echo $regs[1]; 展开
$fp = @fopen($url, "r") or die("超时");
$fcontents = file_get_contents($url);
preg_match("/<div id=\"content\"><p class=\"MsoNormal\" style=\"margin: 0cm 0cm 0pt; text-indent: 44.15pt; line-height: 200%; text-align: center; mso-char-indent-count: 2.0\" align=\"center\"><strong style=\"mso-bidi-font-weight: normal\"><span style=\"font-size: 22pt; line-height: 200%; font-family: 宋体\">(.*)<p class=\"MsoNormal\" style=\"margin: 0cm 0cm 0pt; text-indent: 32pt; line-height: 200%; text-align: left; mso-char-indent-count: 2.0\" align=\"left\"><span lang=\"EN-US\" style=\"font-size: 16pt; line-height: 200%; font-family: 宋体\"><o:p> </o:p></span></p></div>
<div id=\"pageString\"></div>/", $fcontents, $regs);
//echo $regs;
//$regs[1]=str_replace("src=\"../images/","src=\"http://weather.tq121.com.cn/images/",$regs[1]);
$regs[1]=str_replace("<div id=\"title\">","<div align=\"center\">",$regs[1]);
$regs[1]=str_replace("<div id=\"time\">","<div align=\"center\">",$regs[1]);
echo $regs[1]; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询