google.ashx

来自「我写的一个小偷模块 非常实用 内有详细说明」· ASHX 代码 · 共 33 行

ASHX
33
字号
<%@ WebHandler Language="C#" Class="Google" %>
using System;
using System.Web;
using System.Text.RegularExpressions;
using System.Xml;
using System.Text;
//在线翻译的handler
public class Google : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        string[] postname = context.Request.Params.AllKeys;//所有请求的参数
        StringBuilder topost = new StringBuilder();
        for (int i = 0; i < postname.Length; i++)//遍历各参数,构造post字符串
        {
            topost.AppendFormat("{0}={1}&", postname[i], context.Server.UrlEncode(context.Request.Params[postname[i]]));
        }
        //获得翻译结果
        string result = Thief.Post("http://translate.google.com/translate_t", topost.ToString());
        //删除不需要的部分
        result = Regex.Match(result, "<div id=result_box dir=ltr>[\\s\\S]*?</div>").Value;
        result = result.Substring(27);
        result = result.Substring(0, result.Length - 6);
        context.Response.Write(result);//输出
    }
    public bool IsReusable//不重用
    {
        get
        {
            return false;
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?