PHP 採集程式 常用函式

2021-06-25 16:26:09 字數 1904 閱讀 4961

php中喜歡他的採集功能的朋友,就不的不參考下面的函式了,他們就是php採集程式中,常用的一些函式收集

當前的指令碼**

function get_php_url()else

return $nowurl;

}//把全形數字轉為半形數字

function getalabnum($fnum)","",$fnum);

if($fnum=="") $fnum=0;

return $fnum;

}//去除html標記

function text2html($txt)/isu","

\r\n",$txt);

return $txt;

}//清除html標記

function clearhtml($str)

//相對路徑轉化成絕對路徑

function relative_to_absolute($content, $feed_url)

if (isset($protocol[0])) else

return $new_content;

}//取得所有鏈結

function get_all_url($code)

//獲取指定標記中的內容

function get_tag_data($str, $start, $end)

$str = explode($start, $str);

$str = explode($end, $str[1]);

return $str[0];

}//html**的每行轉為csv格式陣列

function get_tr_array($table) ",$table);

//去掉 html 標記

$table = preg_replace("'<[\/\!]*?[^<>]*?>'si","",$table);

//去掉空白字元

$table = preg_replace("'([\r\n])[\s]+'","",$table);

$table = str_replace(" ","",$table);

$table = str_replace(" ","",$table);

$table = explode(",",$table);

array_pop($table);

return $table;

}//將html**的每行每列轉為陣列,採集**資料

function get_td_array($table) ",$table);

$table = str_replace("","",$table);

//去掉 html 標記

$table = preg_replace("'<[\/\!]*?[^<>]*?>'si","",$table);

//去掉空白字元

$table = preg_replace("'([\r\n])[\s]+'","",$table);

$table = str_replace(" ","",$table);

$table = str_replace(" ","",$table);

$table = explode('', $table);

array_pop($table);

foreach ($table as $key=>$tr) ', $tr);

array_pop($td);

$td_array = $td;

}return $td_array;

}//返回字串中的所有單詞 $distinct=true 去除重複

function split_en_str($str,$distinct=true)

sort($match[1]);

return $match[1];

}

PHP採集程式常用的採集函式

這幾天關注了一下php的採集程式,才發現用php採集內容是這麼方便,把經常用到的採集函式在這裡總結一下,方便以後使用 function getallurl code else fnum if fnum fnum 0 return fnum 去除html標記 function text2html tx...

php 採集常用函式 PHP 採集程式中常用的函式

獲得當前的指令碼 function get php url if empty server request uri scriptname server request uri nowurl scriptname else scriptname server php self if empty ser...

php 採集常用函式 PHP常用採集函式

獲取所有鏈結內容和位址function getallurl code 獲取所有的位址 function getimgsrc code else fnum if fnum fnum 0 return fnum 去除html標記 function text2html txt isu r n txt re...