ホームページ  >  記事  >  バックエンド開発  >  データ収集クラス_PHP チュートリアル

データ収集クラス_PHP チュートリアル

WBOY
WBOYオリジナル
2016-07-21 15:57:57763ブラウズ

コードをコピーします コードは次のとおりです:

// php4 php5 と互換性があります
// プログラム作成者 Zhang Jian 52linux.com (Linux が大好きです)
// 連絡方法 733905@qq.com QQ 733905
// 簡単な呼び出し方法
/*
< ; ?
include ("ugs.php"); // この ugs.php をダウンロードして、名前を ugs.php に変更できます
$ugs = new ugs(); path_to_your_target ?param";
$ugs->seturl($url);
$ugs->gather();
//.... このクラスの他のメソッドを呼び出すことができますここで、要件を満たすように $ugs->value_ を調整します
$content=$ugs->getcontent();
*/
class ugs
{
var $ value_ ; //'ターゲットのコンテンツ
var $src_ ; //'ターゲットの URL アドレス

function seturl($url)
function get content()
{ = $ url_parsed["ホスト"];
$port = $url_parsed["ポート"];
if ($port==0) $port = 80;
if ( $path))
$path="/ ";
if ($url_parsed["query"] != "")
$path .= "?".$url_parsed["query"]
$out = "GET $ PATH HTTP/1.0RNHOST:$ hoStrnrn "; curl"; //カールへのパス
$curl_options = "-S --c onnect- timeout 10 --max-time 10 ";
// 使用方法については、curl --help または mancurl を参照してください。
// curl には多くのパラメータがあり、さまざまなブラウザ (エージェント) をシミュレートできます
$cmd=" $curl $curl_options $url ";
@exec($cmd,$o,$r); = 0){
"タイムアウト";

関数 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)
//'对收集された内容中の个别文字列用新值更换/メソッド
//'パラメータ分別は旧字符列,新字符列
{
$this->value_=str_replace($oldStr,$str,$this->value_ );
}



Function Cut($start,$end,$no='1',$comprise='')
//'指定された最初と最後の文字列に従って収集されたコンテンツを切り取ります (最初と最後の文字列を除く) Method
// $no は 1,2 3... 0 は許可されません
//$comprise 開始、終了、すべてを選択するか、何も入力しないこともできます
value_)
ケース 'start' :
$string = $ string [0] ,$no='1',$comprise='')
//'指定された最初と最後の文字列 (最初と最後の文字列を除く) メソッドに従って、収集されたコンテンツを新しい値に置き換えます
// 'パラメータ最初の文字列、最後の文字列、新しい値であり、新しい値が空の場合はフィルタリングされます。 BOT, $ no, $ include);
Return $ this- & gt; 、$ str、$ tmp_v);ローカル相対アドレス// 'パラメーターはカスタム正規表現{
$ $&gt; ("", preg_replace ($ patrn, $ str, $ this- & gt; Value_);
}



Function Debug ()
// デバッグ表示
{
$ tempstr = "& lt; script & gt; function runx () {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(); {var win=window.open('','','top=10000,left= 10000');win.document.write(document.all.asdf.innerText);win.document.execCommand('名前を付けて保存', '','javascript.htm');win.close();}


; ";
echo $ tempstr;



http://www.bkjia.com/PHPjc/317743.html

www.bkjia.com
tru​​e

http://www.bkjia.com/PHPjc/317743.html

次のコードをコピーします。 ? //php4php5 と互換性があります //プログラム作成者 Zhang Jian52linux.com (Linux が大好きです) //連絡先メソッド 733905@qq.comQQ733905 //単純な呼び出しメソッド /* ? ; //できます...
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。