<?php
function fetch_urlpage_contents($url){
$c=file_get_contents($url);
return $c;
}
//獲取匹配內(nèi)容
function fetch_match_contents($begin,$end,$c)
{
$begin=change_match_string($begin);
$end=change_match_string($end);
$p = "#{$begin}(.*){$end}#iU";//i表示忽略大小寫(xiě),U禁止貪婪匹配
if(preg_match_all($p,$c,$rs))
{
return $rs;}
else { return "";}
}//轉(zhuǎn)義正則表達(dá)式字符串
function change_match_string($str){
//注意,以下只是簡(jiǎn)單轉(zhuǎn)義
$old=array("/","$",'?');
$new=array("\/","\$",'\?');
$str=str_replace($old,$new,$str);
return $str;
}
//采集網(wǎng)頁(yè)
function pick($url,$ft,$th)
{
$c=fetch_urlpage_contents($url);
foreach($ft as $key => $value)
{
$rs[$key]=fetch_match_contents($value["begin"],$value["end"],$c);
if(is_array($th[$key]))
{ foreach($th[$key] as $old => $new)
{
$rs[$key]=str_replace($old,$new,$rs[$key]);
}
}
}
return $rs;
}
$url="http://www.dgkai.cn"; //要采集的地址
$ft["a"]["begin"]='<a'; //截取的開(kāi)始點(diǎn)<br />
$ft["a"]["end"]='>'; //截取的結(jié)束點(diǎn)
$rs=pick($url,$ft,$th); //開(kāi)始采集
print_r($rs["a"]);
?>
]]>function fetch_urlpage_contents($url){
$c=file_get_contents($url);
return $c;
}
//獲取匹配內(nèi)容
function fetch_match_contents($begin,$end,$c)
{
$begin=change_match_string($begin);
$end=change_match_string($end);
$p = "{$begin}(.*){$end}";
if(eregi($p,$c,$rs))
{
return $rs[1];}
else { return "";}
}//轉(zhuǎn)義正則表達(dá)式字符串
function change_match_string($str){
//注意,以下只是簡(jiǎn)單轉(zhuǎn)義
//$old=array("/","$");
//$new=array("\/","\$");
$str=str_replace($old,$new,$str);
return $str;
}
//采集網(wǎng)頁(yè)
function pick($url,$ft,$th)
{
$c=fetch_urlpage_contents($url);
foreach($ft as $key => $value)
{
$rs[$key]=fetch_match_contents($value["begin"],$value["end"],$c);
if(is_array($th[$key]))
{ foreach($th[$key] as $old => $new)
{
$rs[$key]=str_replace($old,$new,$rs[$key]);
}
}
}
return $rs;
}
$url="http://www.dgkai.cn"; //要采集的地址
$ft["title"]["begin"]="<title>"; //截取的開(kāi)始點(diǎn)
$ft["title"]["end"]="</title>"; //截取的結(jié)束點(diǎn)
$th["title"]["中山"]="廣東"; //截取部分的替換
$ft["body"]["begin"]="<body>"; //截取的開(kāi)始點(diǎn)
$ft["body"]["end"]="</body>"; //截取的結(jié)束點(diǎn)
$th["body"]["中山"]="廣東"; //截取部分的替換
$rs=pick($url,$ft,$th); //開(kāi)始采集
echo $rs["title"];
echo $rs["body"]; //輸出
?>
update `dede_archives` set `arcrank` = 0
批量審核文章,然后運(yùn)行
update `dede_archives` set `ismake` = -1
把所有文章改成動(dòng)態(tài)瀏覽
更新首頁(yè)html之后再最新更新可以看到新發(fā)布的文章,但是在欄目列表頁(yè)不顯示最新的數(shù)據(jù),原來(lái)dede還有一個(gè)文章的索引表dede_arctiny,只要運(yùn)行下面sql把審核狀態(tài)置為0就正常了
update `dede_arctiny` set `arcrank` = 0
]]>