主頁 > 知識庫 > Web代理(Asp版)

Web代理(Asp版)

熱門標(biāo)簽:團購網(wǎng)站 服務(wù)器配置 阿里云 科大訊飛語音識別系統(tǒng) Mysql連接數(shù)設(shè)置 銀行業(yè)務(wù) 電子圍欄 Linux服務(wù)器
asp寫Web代理軟件,可以用作突破網(wǎng)關(guān)限制等,主要是為了配合Ajax使用的(因Firefox存在跨域訪問的問題) 版本 0.1 作者 LlinZzi
功能
判斷網(wǎng)站編碼,支持任何語言
超連接自動轉(zhuǎn)換
附帶一個遠(yuǎn)程下載圖片的函數(shù)
未解決問題,目前只能用來代理網(wǎng)站代碼,圖片等其他數(shù)據(jù)的代理轉(zhuǎn)發(fā)尚未完成。
復(fù)制代碼 代碼如下:

%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
%Response.Charset = "utf-8"%>
%
Server.ScriptTimeout=9999999;

var Surl = String(Request.QueryString("url"));
if(Surl == "undefined"){
Response.Write("p style=\"font-size:9pt;margin:30px;padding:10px;text-align:center;background-color:#FFCCCC;border: 1px solid #999999;\">Asp代理 by Llinzzi/p>");
Response.Write("div style=\"font-size:9pt;margin:30px;text-align:center;background-color:#FFFFCC;border: 1px solid #999999;\">");
Response.Write("form action=\"#\" method=\"get\" >");
Response.Write("p style=\"font-size:9pt;margin:5px;text-align:center;\">請輸入網(wǎng)址/p>");
Response.Write("p>input style=\"background-color: #FFCCCC;border: 1px solid #999999;\" type=\"text\" name=\"url\">/p>");
Response.Write("p>input style=\"background-color: #FFCCCC;border: 1px solid #999999;\" type=\"submit\"  value=\"GoWeb\">/p>");
Response.Write("/div>");
}
else if(Surl == ""){
Response.Write("p style=\"font-size:9pt;margin:30px;padding:10px;text-align:center;background-color:#FFCCCC;border: 1px solid #999999;\">Asp代理 by Llinzzi/p>");
Response.Write("div style=\"font-size:9pt;margin:30px;text-align:center;background-color:#FFFFCC;border: 1px solid #999999;\">");
Response.Write("p>地址為空,請格式輸入 如 www.tom.com /p>");
Response.Write("/div>");
}
else{
Surl = (Surl.substr(0,7) != "http://") ? "http://"+Surl : Surl;
Response.Write(send_request(Surl));
}

function send_request(url) {
    var codedtext;
    http_request = Server.CreateObject("Microsoft.XMLHTTP");
    try{
    http_request.Open("GET",url,false);
    http_request.Send(null);
    }
    catch(e)
    {
    Response.Write(e.description);
    }
    if (http_request.ReadyState == 4){
        //自動判斷編碼開始
        var charresult = http_request.ResponseText.match(/CharSet=(\S+)"/i);
        if (charresult != null){
        var Cset = charresult[1];
        }else{Cset = "utf-8"}
        //自動判斷編碼結(jié)束
        codedtext = bytesToBSTR(http_request.Responsebody,Cset);
        }else{
        codedtext = "Erro";
        }
        //替換超連接
        codedtext = codedtext.replace(/href="\/?/ig,"href=\""+url+"/");
        codedtext = codedtext.replace(/(a.*href=")/ig,"$1servergate.asp?url=");

    return(codedtext);
}

function bytesToBSTR(body,Cset){
    var objstream;
    objstream = Server.CreateObject("Adodb.Stream");
    objstream.Type = 1;
    objstream.Mode = 3;
    objstream.Open();
    objstream.Write(body);
    objstream.Position = 0;
    objstream.Type = 2;
    objstream.Charset = Cset;
    bytesToBSTR = objstream.Readtext;
    objstream.Close;
    return(bytesToBSTR);
}

function SaveRemoteFile(LocalFileName,RemoteFileUrl){
    var Retrieval,Ads;
    Retrieval = Server.CreateObject("Microsoft.XMLHTTP");
    Retrieval.Open("GET",RemoteFileUrl,false);
    Retrieval.Send(null);
    if (Retrieval.ReadyState == 4){
    Ads = Server.CreateObject("Adodb.Stream");
    Ads.Type = 1;
    Ads.Open();
    Ads.Write(Retrieval.Responsebody);
    Ads.SaveToFile(Server.MapPath(LocalFileName),2);
    Ads.Cancel;
    Ads.Close;
    }
}
//SaveRemoteFile("aa.gif","http://www.baidu.com/img/logo.gif");
%>

標(biāo)簽:衡水 棗莊 萍鄉(xiāng) 廣元 大理 衢州 江蘇 蚌埠

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Web代理(Asp版)》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266