获取转向地址的URL的源文件(可自定义REFER)_实用技巧

软件下载:
http://test.fzclx.com/caixi/geturl.rar

程式源文件:

CS打包:http://test.fzclx.com/caixi/geturl.cs.rar

c#写的,可能要先安装framework.
http://www.microsoft.com/downloads/info.aspx?na=0&p=4&SrcDisplayLang=zh-cn&SrcCategoryId=&SrcFamilyId=&genscs=&u=%2fdownloads%2fdetails.aspx%3fFamilyID%3d262d25e3-f589-4842-8157-034d1e7cf3a3%26displaylang%3dzh-cn

下面是代码:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net;
using System.IO;

namespace WindowsApplication4
{
        /// <summary>
        /// Form1 的摘要说明。
        /// </summary>
        public class Form1 : System.Windows.Forms.Form
        {
                private System.Windows.Forms.Label label2;
                private System.Windows.Forms.Button button1;
                private System.Windows.Forms.Label label1;
                private System.Windows.Forms.TextBox realurl;
                private System.Windows.Forms.TextBox formurl;
                private System.Windows.Forms.Label label3;
                private System.Windows.Forms.TextBox formreferer;
                private System.Windows.Forms.Panel panel1;
                /// <summary>
                /// 必需的设计器变量。
                /// </summary>
                private System.ComponentModel.Container components = null;

                public Form1()
                {
                        //
                        // Windows 窗体设计器支持所必需的
                        //
                        InitializeComponent();

                        //
                        // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
                        //
                }

                /// <summary>
                /// 清理所有正在使用的资源。
                /// </summary>
                protected override void Dispose( bool disposing )
                {
                        if( disposing )
                        {
                                if (components != null)
                                {
                                        components.Dispose();
                                }
                        }
                        base.Dispose( disposing );
                }

                #region Windows 窗体设计器生成的代码
                /// <summary>
                /// 设计器支持所需的方法 - 不要使用代码编辑器修改
                /// 此方法的内容。
                /// </summary>
                private void InitializeComponent()
                {
                        System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
                        this.formurl = new System.Windows.Forms.TextBox();
                        this.label2 = new System.Windows.Forms.Label();
                        this.button1 = new System.Windows.Forms.Button();
                        this.label1 = new System.Windows.Forms.Label();
                        this.realurl = new System.Windows.Forms.TextBox();
                        this.label3 = new System.Windows.Forms.Label();
                        this.formreferer = new System.Windows.Forms.TextBox();
                        this.panel1 = new System.Windows.Forms.Panel();
                        this.SuspendLayout();
                        //
                        // formurl
                        //
                        this.formurl.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                        this.formurl.ForeColor = System.Drawing.SystemColors.WindowText;
                        this.formurl.Location = new System.Drawing.Point(24, 32);
                        this.formurl.Name = "formurl";
                        this.formurl.Size = new System.Drawing.Size(288, 21);
                        this.formurl.TabIndex = 0;
                        this.formurl.Text = "http://";
                        this.formurl.TextChanged += new System.EventHandler(this.formurl_TextChanged);
                        //
                        // label2
                        //
                        this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
                        this.label2.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                        this.label2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
                        this.label2.Location = new System.Drawing.Point(24, 16);
                        this.label2.Name = "label2";
                        this.label2.Size = new System.Drawing.Size(128, 17);
                        this.label2.TabIndex = 2;
                        this.label2.Text = "输入你要获取的网址:";
                        this.label2.Click += new System.EventHandler(this.label2_Click);
                        //
                        // button1
                        //
                        this.button1.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(64)), ((System.Byte)(64)), ((System.Byte)(64)));
                        this.button1.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
                        this.button1.Location = new System.Drawing.Point(320, 32);
                        this.button1.Name = "button1";
                        this.button1.Size = new System.Drawing.Size(56, 64);
                        this.button1.TabIndex = 3;
                        this.button1.Text = "获取…";
                        this.button1.Click += new System.EventHandler(this.button1_Click);
                        //
                        // label1
                        //
                        this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
                        this.label1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                        this.label1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
                        this.label1.Location = new System.Drawing.Point(24, 104);
                        this.label1.Name = "label1";
                        this.label1.Size = new System.Drawing.Size(128, 17);
                        this.label1.TabIndex = 5;
                        this.label1.Text = "真实的网址:";
                        this.label1.Click += new System.EventHandler(this.label1_Click);
                        //
                        // realurl
                        //
                        this.realurl.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                        this.realurl.ForeColor = System.Drawing.Color.OrangeRed;
                        this.realurl.Location = new System.Drawing.Point(24, 120);
                        this.realurl.Name = "realurl";
                        this.realurl.Size = new System.Drawing.Size(352, 21);
                        this.realurl.TabIndex = 4;
                        this.realurl.Text = "";
                        //
                        // label3
                        //
                        this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
                        this.label3.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                        this.label3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
                        this.label3.Location = new System.Drawing.Point(24, 56);
                        this.label3.Name = "label3";
                        this.label3.Size = new System.Drawing.Size(128, 17);
                        this.label3.TabIndex = 7;
                        this.label3.Text = "伪装来路:";
                        //
                        // formreferer
                        //
                        this.formreferer.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                        this.formreferer.Location = new System.Drawing.Point(24, 72);
                        this.formreferer.Name = "formreferer";
                        this.formreferer.Size = new System.Drawing.Size(288, 21);
                        this.formreferer.TabIndex = 6;
                        this.formreferer.Text = "http://";
                        //
                        // panel1
                        //
                        this.panel1.BackColor = System.Drawing.Color.LightGray;
                        this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                        this.panel1.Location = new System.Drawing.Point(18, 13);
                        this.panel1.Name = "panel1";
                        this.panel1.Size = new System.Drawing.Size(364, 130);
                        this.panel1.TabIndex = 8;
                        //
                        // Form1
                        //
                        this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
                        this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
                        this.ClientSize = new System.Drawing.Size(392, 165);
                        this.Controls.Add(this.label3);
                        this.Controls.Add(this.formreferer);
                        this.Controls.Add(this.label1);
                        this.Controls.Add(this.realurl);
                        this.Controls.Add(this.button1);
                        this.Controls.Add(this.label2);
                        this.Controls.Add(this.formurl);
                        this.Controls.Add(this.panel1);
                        this.Name = "Form1";
                        this.Text = "取得真实URL -- 落伍的caixi www.im286.com";
                        this.Load += new System.EventHandler(this.Form1_Load);
                        this.ResumeLayout(false);

                }
                #endregion

                /// <summary>
                /// 应用程序的主入口点。
                /// </summary>
                [STAThread]
                static void Main()
                {
                        Application.Run(new Form1());
                }

                private void Form1_Load(object sender, System.EventArgs e)
                {

                }

                private void label2_Click(object sender, System.EventArgs e)
                {

                }

                private void button1_Click(object sender, System.EventArgs e)
                {        
                        string Theurl=formurl.Text;
                        string Referurl=formreferer.Text;
                        if (Theurl.Length<10)
                        {
                                MessageBox.Show("兄弟,URL不正确吧","URL不正确");
                                formurl.Focus();
                        }
                        else
                        {
                                HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create(Theurl);
                                myReq.Referer=Referurl;
                                HttpWebResponse myres=(HttpWebResponse)myReq.GetResponse();
                                bool hasChanged = (myReq.RequestUri != myReq.Address);
                                string geturl;
                                if (hasChanged){
                                        geturl=myReq.Address.ToString();
                                }
                                else{
                                        geturl=myReq.RequestUri.ToString();
                                }
                                realurl.Text=geturl;
                                realurl.Focus();
                        }
                }

                private void label1_Click(object sender, System.EventArgs e)
                {

                }

                private void formurl_TextChanged(object sender, System.EventArgs e)
                {

                }
        }

时间: 2024-09-25 08:23:15

获取转向地址的URL的源文件(可自定义REFER)_实用技巧的相关文章

asp.net 页面转向 Response.Redirect, Server.Transfer, Server.Execute的区别_实用技巧

Response.Redirect 简单地发送一条消息到浏览器,告诉浏览器定位到另一个页面.你可以使用下面的代码将用户引导到另一个页面: Response.Redirect("WebForm2.aspx") 或者 Response.Redirect("http://www.cnnas.com/") Server.Transfer 也是通过一条语句将用户引导到另一页面,比如:Server.Transfer("WebForm2.aspx").不过,这

Global.asax的Application_BeginRequest实现url重写无后缀的代码_实用技巧

利用Global.asax的Application_BeginRequest 实现url 重写 无后缀 复制代码 代码如下: <%@ Application Language="C#" %> <script RunAt="server"> void Application_BeginRequest(object sender, EventArgs e) { string oldUrl = System.Web.HttpContext.Curr

获取远程网页的内容之一(downmoon原创)_实用技巧

获取远程网页的内容之一(downmoon原创) 一.本机直接上网时: 获取指定远程网页内容#region 获取指定远程网页内容      复制代码 代码如下:     /**//// <summary>          /// 获取指定远程网页内容          /// </summary>          /// <param name="strUrl">所要查找的远程网页地址</param>          /// <

ASP.NET实现根据URL生成网页缩略图的方法_实用技巧

本文实例讲述了ASP.NET实现根据URL生成网页缩略图的方法.分享给大家供大家参考,具体如下: 工作中需要用到根据URL生成网页缩略图功能,提前做好准备. 在网上找了份源码,但是有错误:当前线程不在单线程单元中,因此无法实例化 ActiveX 控件"8856f961-340a-11d0-a9",解决后运行良好,记录在此备用! 起始页:Default.aspx <%@ Page Language="C#" AutoEventWireup="true&

.NET获取枚举DescriptionAttribute描述信息性能改进的多种方法_实用技巧

一. DescriptionAttribute的普通使用方式 1.1 使用示例 DescriptionAttribute特性可以用到很多地方,比较常见的就是枚举,通过获取枚举上定义的描述信息在UI上显示,一个简单的枚举定义: public enum EnumGender { None, [System.ComponentModel.Description("男")] Male, [System.ComponentModel.Description("女")] Fem

asp.net url重写的好处与方法_实用技巧

url重写的好处: 1,方便搜索引擎检索到(html格式的网站搜索引擎记住的优先级最高,seo优化更好) 2,url更加简洁,方便用户记忆 3,隐藏网页的实际路劲和具体开发技术 使用URLRewriter.dll重写 使用URLRewriter.dll后,只需要使用如下步骤将可以进行url重写 1,在webconfig下写入 复制代码 代码如下: <Rules>       <!-- 规则1 -->       <RewriterRule>         <Lo

asp.net url重写后页面回传问题_实用技巧

具体办法如下:可以通过自定义页面基类,重写默认的HtmlTextWriter方法,重写属性输出WriteAttribute(string name, string value, bool encode)方法,当输出action时,将action属性的值强制转换为当前虚URL(HttpContext.Current.Request.RawUrl,上面的~/showVisasAll_(\w+)\.aspx) 最后就是让所有的页面都调用这个基类,修改一下Web.config就好了 <!-- Openl

asp.net 获取指定文件夹下所有子目录及文件(树形)_实用技巧

#region 获取指定文件夹下所有子目录及文件(树形)         /****************************************          * 函数名称:GetFoldAll(string Path)          * 功能说明:获取指定文件夹下所有子目录及文件(树形)          * 参    数:Path:详细路径          * 调用示列:          *           string strDirlist = Server.M

asp.net中C#获取字符串中汉字的个数的具体实现方法_实用技巧

符串可以包括数字,字母,汉字或者其他的字符.使用Char类型的IsDigit静态方法可以判断字符串中的字符是否为数字,使用Char类型中的IsLetter静态方法可以判断字符串中是否为字母.我们来实现一种方法来实现判断字符串中是否为汉字,通过此方法可以计算字符串中汉字的个数,运行效果如图: 首先根据效果图设置好Form的界面和内容,Box1.Text为输入的字符串,我们对该字符串的处理,来计算汉字的个数,双击Buton控件,编辑其单击事件代码. 我们看下汉字的Unicode范围,普遍给出了0x4