欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

一個數(shù)據(jù)采集類

 更新時間:2007年02月14日 00:00:00   作者:  
復(fù)制代碼 代碼如下:

<?
// 兼容 php4 php5
// 程序作者  張建 52linux.com(我愛Linux)
// 聯(lián)系方法  733905@qq.com  QQ 733905 
// 簡單調(diào)用方法
/*
<?
include ("ugs.php"); // 你可以下載本ugs.phps 然后重命名為ugs.php
$ugs = new ugs();
$url = "http://domainname.com/path_to_your_target?param";
$ugs->seturl($url);
$ugs->gather();
//............這里可以調(diào)用本類里的其它方法,對$ugs->value_  做調(diào)整,
以滿足您的要求
$content=$ugs->getcontent();
print($content);
?>
*/
class ugs
{
    var $value_  ;  //'目標內(nèi)容
    var $src_    ;  //'目標URL地址

    function seturl($url)
    {
        $this->src_=$url;
    }
    function getcontent()
    {
        return $this->value_;
    }
    function getfile($url)
     // 獲取目標
    {
        $url_parsed = parse_url($url);
        $host = $url_parsed["host"];
        $port = $url_parsed["port"];
        if ($port==0)  $port = 80;
        $path = $url_parsed["path"];
        if (empty($path))
        $path="/";
        if ($url_parsed["query"] != "")
           $path .= "?".$url_parsed["query"];
        $out = "GET $path HTTP/1.0\r\nHost: $host\r\n\r\n";
        $fp = fsockopen($host, $port, $errno, $errstr, 30);
        fwrite($fp, $out);
        $body = false;
        while (!feof($fp))
        {
          $s = fgets($fp, 1024);
          if ( $body )  $in .= $s;
          if ( $s == "\r\n" )
               $body = true;
        }
        fclose($fp);
        return $in;
   }

   function getfile_curl($url)
   {
    $curl="/usr/local/bin/curl " ; // path to your curl 
    $curl_options=" -s --connect-timeout 10  --max-time 10  "; 
    // curl 用法請參考 curl --help 或者 man curl 
    // curl 參數(shù)非常之豐富,可以模擬各種瀏覽器(agent) 可以設(shè)置referer
    $cmd="$curl $curl_options $url ";
    @exec($cmd,$o,$r);
    if($r!=0) 
    {
        return "超時";
    }
    else
    {
        $o=join("",$o);
        return $o;
    }
   }

    function gather_curl($curl)
    {
        $http=$this->getfile_curl($this->src_);
        return $this->value_=$http;
    }

    function gather_array($url)
     {
        return file($url);
    }

    function   gather()
     // 開始收集
    {
        $http=$this->getfile($this->src_);
        return $this->value_=$http;
    }

    function gather_local($toline=true)
     // 處理本地文件
    {

        if($toline)
        {
            $http=file($this->src_);
            return $this->value_=$this->BytesToBstr($http);
        }
        else
        {
            $http=file($this->src_);
            return $this->value_=$http;
        }



    }

    function noReturn()
     // 刪除回車換行
    {
        $this->value_=str_replace("\n","",$this->value_);
        $this->value_=str_replace("\r","",$this->value_);
    }


    function change($oldStr,$str)
    //'對收集到的內(nèi)容中的個別字符串用新值更換/方法
    //'參數(shù)分別是舊字符串,新字符串
    {
        $this->value_=str_replace($oldStr,$str,$this->value_ );
    }



    function cut($start,$end,$no='1',$comprise='')
    //'按指定首尾字符串對收集的內(nèi)容進行裁減(不包括首尾字符串)方法
    // $no 必須是 1,2 3 ... 不允許是0
    //$comprise 可以選擇 start 或者 end 或者 all 或者 什么都不填
    {
        $string=explode($start,$this->value_);
        //print_r($string);
        $string=explode($end,$string[$no]);
        //print_r($string);
        switch ($comprise){
                case 'start':
                        $string=$start.$string[0];
                break;
                case 'end':
                        $string=$string[0].$end;
                break;
                case 'all':
                        $string=$start.$string[0].$end;
                break;
                default:
                        $string=$string[0];
        }
        return $this->value_=$string;
        }


    function  filt($head,$bot,$str,$no='1',$comprise='')
    //'按指定首尾字符串對收集的內(nèi)容用新值進行替換(不包括首尾字符串)方法
    // '參數(shù)分別是首字符串,尾字符串,新值,新值位空則為過濾
    {
        $tmp_v=$this->value_;
        $tmp=$this->cut($head,$bot,$no,$comprise);
        return $this->value_=str_replace($tmp,$str,$tmp_v);
    }



    function  local()
    {
        //'將收集的內(nèi)容中的絕對URL地址改為本地相對地址
        // 還沒實現(xiàn)
    }



    function  replaceByReg($patrn,$str)
     //'對收集的內(nèi)容中的符合正則表達式的字符串用新值進行替換/方法
     //'參數(shù)是你自定義的正則表達式,新值
    {
        return $this->value_=join("",preg_replace($patrn,$str,$this->value_));
    }



    function debug()
    //調(diào)試顯示
    {
        $tempstr="<SCRIPT>function runEx(){var winEx2 = window.open(\"\", \"winEx2\", \"width=500,height=300,status=yes,menubar=no,scrollbars=yes,resizable=yes\"); winEx2.document.open(\"text/html\", \"replace\"); winEx2.document.write(unescape(event.srcElement.parentElement.children[0].value)); winEx2.document.close(); }function saveFile(){var win=window.open('','','top=10000,left=10000');win.document.write(document.all.asdf.innerText);win.document.execCommand('SaveAs','','javascript.htm');win.close();}</SCRIPT><center><TEXTAREA id=asdf name=textfield rows=32  wrap=VIRTUAL cols=\"120\">".$this->value_."</TEXTAREA><BR><BR><INPUT name=Button onclick=runEx() type=button value=\"查看效果\">&nbsp;&nbsp;<INPUT name=Button onclick=asdf.select() type=button value=\"全選\">&nbsp;&nbsp;<INPUT name=Button onclick=\"asdf.value=''\" type=button value=\"清空\">&nbsp;&nbsp;<INPUT onclick=saveFile(); type=button value=\"保存代碼\"></center>";
        echo $tempstr;
    }


}
?>

相關(guān)文章

  • php獲取指定范圍內(nèi)最接近數(shù)的方法

    php獲取指定范圍內(nèi)最接近數(shù)的方法

    這篇文章主要介紹了php獲取指定范圍內(nèi)最接近數(shù)的方法,可實現(xiàn)根據(jù)給定區(qū)間長度劃分各個區(qū)間,并在其中尋找與給定數(shù)最接近的數(shù),需要的朋友可以參考下
    2015-06-06
  • php結(jié)合安卓客戶端實現(xiàn)查詢交互實例

    php結(jié)合安卓客戶端實現(xiàn)查詢交互實例

    本文給大家分享的是php結(jié)合安卓客戶端實現(xiàn)查詢交互實例,java端主要分三步來實現(xiàn):首先進行 http request.網(wǎng)絡(luò)請求相關(guān)操作,第二步,使用execute方法發(fā)送HTTP GET請求,并返回HttpResponse對象,第三步,使用getEntity方法活得返回結(jié)果。有需要的小伙伴參考下
    2015-05-05
  • PHP中英混合字符串截取函數(shù)代碼

    PHP中英混合字符串截取函數(shù)代碼

    今天在遇到了一個中英字符串截取的問題,在gbk里中文里每個字占兩字節(jié),如果全是中文的話,用substr()函數(shù)就可以實現(xiàn)了,但中英都有的話就麻煩了,在以前收藏的代碼里找到了一個不錯的函數(shù),很好的實現(xiàn)了截取的功能
    2011-07-07
  • PHP封裝的HttpClient類用法實例

    PHP封裝的HttpClient類用法實例

    這篇文章主要介紹了PHP封裝的HttpClient類,可實現(xiàn)簡單的GET、POST、Cookie、Session等功能,需要的朋友可以參考下
    2015-06-06
  • php的RSA加密解密算法原理與用法分析

    php的RSA加密解密算法原理與用法分析

    這篇文章主要介紹了php的RSA加密解密算法原理與用法,結(jié)合實例形式分析了rsa加密解密算法的相關(guān)概念、原理及PHP使用RSA加密解密算法的具體實現(xiàn)技巧,需要的朋友可以參考下
    2020-01-01
  • RSA實現(xiàn)JS前端加密與PHP后端解密功能示例

    RSA實現(xiàn)JS前端加密與PHP后端解密功能示例

    這篇文章主要介紹了RSA實現(xiàn)JS前端加密與PHP后端解密功能,結(jié)合實例形式分析了rsa前端js加密與后端php解密相關(guān)操作技巧,需要的朋友可以參考下
    2019-08-08
  • dede全站URL靜態(tài)化改造[070414更正]

    dede全站URL靜態(tài)化改造[070414更正]

    dede全站URL靜態(tài)化改造[070414更正]...
    2007-04-04
  • PHP測試程序運行時間的類

    PHP測試程序運行時間的類

    今天,為了測試一斷程序的運行時間,特意寫了這么一個類,并添加了注釋,希望對大家有所幫助
    2012-02-02
  • PHP move_uploaded_file() 函數(shù)(將上傳的文件移動到新位置)

    PHP move_uploaded_file() 函數(shù)(將上傳的文件移動到新位置)

    這篇文章主要介紹了PHP move_uploaded_file() 函數(shù),其實就是將上傳的文件移動到新位置,需要的朋友可以參考下
    2018-03-03
  • php中mkdir()函數(shù)的權(quán)限問題分析

    php中mkdir()函數(shù)的權(quán)限問題分析

    這篇文章主要介紹了php中mkdir()函數(shù)的權(quán)限問題分析,需要的朋友可以參考下
    2016-09-09

最新評論