畢設寫的簡單spider類 正則等內容

2021-06-15 21:20:15 字數 3240 閱讀 5456

<?php

class spider

//處理url,以符合標準

function dealurl($url)else

if(strrpos($url,'/')==strlen($url)-1)

return $url;

}//取乙個鏈結下的所有鏈結

function geturl($url)else

//echo "    $regs[1]

";$line = $regs[2];

if(strstr($nexturl,$regs[1]))elseelse}}

}}return $nexturl;

}//查詢該url是否需要重新搜尋

function queryurl($url,$contentdesc,$db)else

}//得到大小

function getimglength($url)else

}//取得該url內的位址,及網頁內容,儲存日期,所在伺服器ip,檔案大小

//存入資料庫

echo "完成蒐集:".$url1."";}

}function geturlresponse($url)

//取檔案儲存日期

function geturldate($url)

//取某**對應的ip

function geturlip($url)

//網頁標籤提取函式

function tags($filename,$tag) else

$line=eregi_replace($regs[1],$tmp,$line);

$content=$content.$line;

//echo "    $line

";$line = $regs[2];}}

echo $content;*/

if(strstr($this->geturlresponse($url),"200"))else

$buffer=eregi_replace($regs[1],$tmp,$buffer);

$buffer=eregi_replace("/'","/"",$buffer);

//echo "    $regs[1]";}

if($buffer)}}

function nexturl($url)

$url=$this->nexturl($url);}}

//提取網頁標題函式

function geturltitle($url)

//無亂碼擷取中文字串的函式

function substr_for_gb2312($str,$start,$len=null)

//確定起始位置,當起始位拆分某漢字時,返回值包含此漢字.

if ($start > 0)

else break;

$i--;

}if($flag==1)

}$str = substr($str,$start);//截除字串$str的$start位前的字元

$totlelength = strlen($str);

//確定結束位置,當結束位拆分某漢字時,返回值不包含此漢字.

if ($len<0) $len = $totlelength - abs($len);

if ($len <= 0) return "";

$i=min($len,$totlelength);

$i--;

$flag = -1;

while ($i >= 0)

else break;

$i--;

}if($flag == 1)

$len=$len-1;

$subit=substr($str,0,$len);

return $subit;}}

?> 

寫畢設遇到的sql問題

用的是idea內建的h2資料庫。問題1 判斷是否為空應該用is null,而不是 null。select count from data where disturb time is null or error code num is null or ciphertext notice time is...

寫畢設查詢的問題總結

換行問題 強制不換行p 超出顯示省略號p suwu150 比較日期 改變滑鼠樣式 cursor pointer 手 cursor wait 等待 cursor help 幫助 vue 路由跳轉 this.router.push login this.router.push this.router.p...

python寫的乙個簡單的spider

1.html parser 繼承sgmlparser類,對html頁面中的正文 tag 和錨點 tag 的內容進行提取 2.spider 用urllib開啟html page,通過myparser提取頁面資訊 正文和錨點 通過關鍵字提取有用資訊 只有包含了關鍵字的資訊才會被保留下來,其他資訊都會被捨...