欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

获取转向地址的URL的源文件(可自定义REFER)

程序员文章站 2023-11-13 13:22:40
软件下载:http://test.fzclx.com/caixi/geturl.rar程式源文件:cs打包:http://test.fzclx.com/caixi/getu...
软件下载:
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)
                {

                }
        }