求助.. linux下的php采集程序无法访问外网怎么办? 求助.. linux下的php采集程序无法访问外网怎么办? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在linux下是可以访问外网的,也可以ping通,我把代码贴出来:$strurl="http://www.cma.gov.cn/tqyb/weatherdetail/58367.html";//$strurl="http://www.xishuiw.com/info/2009-2/2009-2-6-15879.htm";$wfileurl="../weather/".$date.".txt";function wstr($n) { return "http://www.cma.gov.cn".$n;}function wstr1($n) { return str_replace("/tqyb/img/weather/","/tqyb/img/weather/a",$n);}if(is_file($wfileurl)){ $handle=fopen($wfileurl, "r"); $weatherstr=fread($handle,filesize($wfileurl)); fclose($handle);}else{ $strhtmlarray=file($strurl); $strlinehtml= implode('%', $strhtmlarray); eregi("3天预报(.*)指数查询", $strlinehtml, $head); preg_match_all("((/tqyb/img/weather/)([0-9]{1,2})\.(\gif))", $head[0],$wimgarr); $wimg = array_map("wstr", $wimgarr[0]); $wimgurl= implode('%', $wimg); $wimg1 = array_map("wstr1", $wimg); $wimgurl1= implode('%', $wimg1); $head[0]=strip_tags($head[0]); $head[0]=str_replace(" ","",$head[0]); $head[0]=str_replace("3天预报","",$head[0]); $head[0]=str_replace("时间","|",$head[0]); $head[0]=str_replace("天气概况","|",$head[0]); $head[0]=str_replace("气 温","|",$head[0]); $head[0]=str_replace("风向/风力","|",$head[0]); $head[0]=str_replace("指数查询","",$head[0]); $head[0]=str_replace(" ","",$head[0]); $head[0].="|".$wimgurl; $head[0].="|".$wimgurl1; $weatherstr=$head[0]; $handle=fopen($wfileurl, "w"); fwrite($handle,$weatherstr); fclose($handle);}其中$strhtmlarray=file($strurl);在window下可以取到内容,但是在linux下就没有办法取到内容 支付宝接口传值问题 phpli连接一个表,让他安不同的方循环出来 求高手指点 不知道能否实现以这种方式的变量值传送? 单选框实现了切换,但提交表单后,怎么去获得提交的内容? 变量未定义和一个警告,找了很久也找不出来!求大神帮忙,谢谢! 工作了3天就不用我了,郁闷的想死!!!!!!!!!!!!! 关于“不能打开注册表关键字”的问题 居然又一次5星了,三分。呵呵。 php有办法作图片锐化功能吗? php+mysql问题 PHP不能使用domxml_open_mem() 方法,在哪下载php_iconv.dll,php_domxml.dll文件
$strurl="http://www.cma.gov.cn/tqyb/weatherdetail/58367.html";
//$strurl="http://www.xishuiw.com/info/2009-2/2009-2-6-15879.htm";
$wfileurl="../weather/".$date.".txt";
function wstr($n) {
return "http://www.cma.gov.cn".$n;
}
function wstr1($n) {
return str_replace("/tqyb/img/weather/","/tqyb/img/weather/a",$n);
}if(is_file($wfileurl))
{
$handle=fopen($wfileurl, "r");
$weatherstr=fread($handle,filesize($wfileurl));
fclose($handle);
}
else
{
$strhtmlarray=file($strurl); $strlinehtml= implode('%', $strhtmlarray);
eregi("3天预报(.*)指数查询", $strlinehtml, $head);
preg_match_all("((/tqyb/img/weather/)([0-9]{1,2})\.(\gif))", $head[0],$wimgarr);
$wimg = array_map("wstr", $wimgarr[0]);
$wimgurl= implode('%', $wimg);
$wimg1 = array_map("wstr1", $wimg);
$wimgurl1= implode('%', $wimg1);
$head[0]=strip_tags($head[0]);
$head[0]=str_replace(" ","",$head[0]);
$head[0]=str_replace("3天预报","",$head[0]);
$head[0]=str_replace("时间","|",$head[0]);
$head[0]=str_replace("天气概况","|",$head[0]);
$head[0]=str_replace("气 温","|",$head[0]);
$head[0]=str_replace("风向/风力","|",$head[0]);
$head[0]=str_replace("指数查询","",$head[0]);
$head[0]=str_replace(" ","",$head[0]);
$head[0].="|".$wimgurl;
$head[0].="|".$wimgurl1;
$weatherstr=$head[0];
$handle=fopen($wfileurl, "w");
fwrite($handle,$weatherstr);
fclose($handle);
}
其中$strhtmlarray=file($strurl);在window下可以取到内容,但是在linux下就没有办法取到内容