日期:2012-05-14  浏览次数:20410 次

由于需要查找资料,只好简单写了一个PHP的服务端代理页面来用一下!

简单框架页面:

以下为引用的内容:

<style type="text/css">
*{margin:0;padding:0;}
html,body{overflow:hidden;}
td{padding:0;vertical-align:top;}
</style>
<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td style="height:25px;background:#d4d0c8;padding:5px 10px;">
<form method="post" action="action_get.php" target="actioncontent" style="margin:0;padding:0;">
<input type="text" id="targeturl" name="targeturl" style="width:100%;border:1px inset;margin:0;" />
</form>
</td>
</tr>
<tr>
<td>
<iframe name="actioncontent" style="width:100%;height:100%;"></iframe>
</td>
</tr>
</table>
<script type="text/javascript">
window.onload = function(){
 document.getElementById('targeturl').focus();
};
</script>

PHP代理页面:

以下为引用的内容:

<?php
//使用Snoopy的抓页功能
include "Snoopy.class.php";
//目标URL
$url = $_REQUEST['targeturl'];
//将所有传递过来的参数列出来
$par = array();
$GetPost = array_merge($_POST,$_GET);
foreach($GetPost As $Key=>$Value){
 if($Key!='targeturl'){
  $Value = str_replace("%25","%",$Value);
  array_push($par,($Key . "=" . $Value));
 }
}
//判断目标URL是否带有?(即是否带有参数)
$cc = strpos($url,"?") ? "&" : "?";
//重组URL
$geturl = !$par ? $url : $url.$cc.implode("&",$par);
//抓取重组后的URL页面内容
$snoopy = new Snoopy;
$snoopy->fetch($geturl);
//替换目标内容中脚本里有可能替换父窗口地址的代码
$org = str_replace("top.location","top.title",$snoopy->results);
//尝试转换目标内容编码到UTF-8
$opt = iconv("gbk","utf-8",$org);
//判断目标内容编码为GBK或UTF-8
$ec = strlen($opt)?"gbk":"utf-8";

?>
<script type="text/javascript">
//封闭运行,避免与后面内容中脚本混乱
(function(){
var easyUTF8 = function(gbk){if(!gbk){return '';}var utf8 = [];for(var i=0;i<gbk.length;i++){var s_str = gbk.charAt(i);if(!(/^%u/i.test(escape(s_str)))){utf8.push(s_str);c