PHP 代码:
<?php
/**
// 程序作者:张建
// 网站:http://www.phpsir.com
// 联系方法:52linux@gmail.com
// 联系方法:QQ 733905
//
示例:
include ("ugs.php"); // 你可以下载本ugs.phps 然后重命名为ugs.php
$ugs = new ugs();
$url = "http://domainname.com/path_to_your_target?param";
$ugs->set($url);
$ugs->gus();
以满足您的要求
$content=$ugs->get();
print($content);
======================================================
使用方法
include ("ugs.php");
$ugs = new ugs();
$url = "http://domainname.com/path_to_your_target?param";
$ugs->set($url);
$ugs->gus();
$content=$ugs->get();
print($content);
*/
class ugs
{
var $value_ ; //'目标内容
var $src_ ; //'目标URL地址
function set($url)
{
$this->src_=$url;
}
function get()
{
return $this->value_;
}
function gus()
{
$this->value_=file_get_contents($this->src_); //(PHP 4 >= 4.3.0, PHP 5)
}
function gaa()
{
$this->value_=file($this->src_);
}
function nor() // 删除回车换行
{
$this->value_=str_replace("\n","",$this->value_);
$this->value_=str_replace("\r","",$this->value_);
}
function chg($oldstr,$newstr) //'对收集到的内容中的个别字符串用新值更换的方法,参数分别是旧字符串,新字符串
{
$this->value_=str_replace($oldstr,$newstr,$this->value_ );
}
function cut($StartFlag,$EndFlag,$no='1',$comprise='')
/*
按指定首尾字符串对收集的内容进行裁减的的方法
$no 必须是 1,2 3 ... 不允许 0
$comprise 可以选择 start 或者 end 或者 all 或者 什么都不填
*/
{
$string=explode($StartFlag,$this->value_);
//print_r($string);
$string=explode($EndFlag,$string[$no]);
//print_r($string);
switch ($comprise){
case 'start':
$string=$StartFlag.$string[0];
break;
case 'end':
$string=$string[0].$EndFlag;
break;
case 'all':
$string=$StartFlag.$string[0].$EndFlag;
break;
default:
$string=$string[0];
}
return $this->value_=$string;
}
function flt($start,$end,$newstr,$no='1',$comprise='')
/*
按指定首尾字符串对收集的内容用新值进行替换(不包括首尾字符串)方法
参数分别是首字符串,尾字符串,新值,新值位空则为过滤
*/
{
$tmp_ori=$this->value_;
if($comprise==''){
$tmp=$this->cut($start,$end,$no);
}else{
$tmp=$this->cut($start,$end,$no,$comprise);
}
$this->value_=str_replace($tmp,$newstr,$tmp_ori);
}
function dbg() //调试显示
{
$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=\"查看效果\"> <INPUT name=Button onclick=asdf.select() type=button value=\"全选\"> <INPUT name=Button onclick=\"asdf.value=''\" type=button value=\"清空\"> <INPUT onclick=saveFile(); type=button value=\"保存代码\"></center>";
echo $tempstr;
}
}
?>