获取转向地址的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)
                {

}
        }
}

(0)

相关推荐

  • 获取转向地址的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

  • Java 获取网络302重定向URL的方法

    方法1: import java.net.HttpURLConnection; import java.net.URL; import org.junit.Assert; import org.junit.Test; public class GetRedirectUrlTest { @Test public void test_getRedirectUrl() throws Exception { String url="http://www.baidu.com/link?url=ByBJLp

  • php获取当前页面完整URL地址

    使用PHP编写程序的时候,我们常常想要获取当前页面的URL.下面提供一个用于获取当前页面URL的函数以及使用方法: 示例一: <?php // 说明:获取完整URL function curPageURL() { $pageURL = 'http'; if ($_SERVER["HTTPS"] == "on") { $pageURL .= "s"; } $pageURL .= "://"; if ($_SERVER[&q

  • nodejs实现获取当前url地址及url各种参数值

    复制代码 代码如下: //需要使用的模块 http   url 当前url   http://localhost:8888/select?aa=001&bb=002 var http = require('http'); var URL = require('url'); http.createServer(function(req, res){    var arg = url.parse(req.url).query;  //方法一arg => aa=001&bb=002   

  • 正则获取图片地址 链接地址

    复制代码 代码如下: reg = /<[img|href][^>]*src\s*=\s*('|")?([^'">]*)\1([^>])*>/ig 正则获取图片地址 一.问题: 采集的过程中遇到一个问题:从数据库里读出来的图片没有正常显示,分析后发现是数据库里的图片以网站根目录为相对路径方式存储,图片地址如:/uploads/allimg/090403/012F31N9-1.jpg,原来做的读取图片是以http://开关的URL绝对图片获取,所以采集中出现以

  • PHP获取当前页面完整URL的方法

    一.利用javascript实现: top.location.href 顶级窗口的地址 this.location.href 当前窗口的地址 二.利用PHP实现 http://localhost/PHP/XX.php?id=5 //获取域名或主机地址 echo $_SERVER['HTTP_HOST']; #localhost //获取网页地址 echo $_SERVER['PHP_SELF']; #/PHP/XX.php //获取网址参数 echo $_SERVER["QUERY_STRING

  • dz asp.net论坛中函数--根据Url获得源文件内容

    需要引入命名空间: 复制代码 代码如下: using System.Net; using System.IO; 函数内容: 复制代码 代码如下: /// <summary> /// 根据Url获得源文件内容 /// </summary> /// <param name="url">合法的Url地址</param> /// <returns></returns> public static string GetSou

  • Java使用正则表达式匹配获取链接地址的方法示例

    本文实例讲述了Java使用正则表达式匹配获取链接地址的方法.分享给大家供大家参考,具体如下: 获取页面中字符串的url地址我们都会使用正则表达式来匹配获取了,下面我来给大家总结几个匹配获取链接地址示例. 1.正则表达式中Matcher中find()方法的应用. 2.String对象中的 replaceAll(String regex,String replacement) 方法的使用.通过这个方法去除了不必要的字符串,从而得到了需要的网址和链接文字 例1.超简单的 String content

  • Linux下Python获取IP地址的代码

    <lnmp一键安装包>中需要获取ip地址,有2种情况:如果服务器只有私网地址没有公网地址,这个时候获取的IP(即私网地址)不能用来判断服务器的位置,于是取其网关地址用来判断服务器在国内还是国外(脚本为了使国内用户快速下载,yum源自动设置成163,这个情况就需要获取网关地址):如果服务器有公网地址,这时获取的IP地址可用来直接判断服务器地理位置. 获取服务器IP,如果有公网地址就取公网地址,没有公网地址就取私网网址 下面是之前我用shell来获取本地IP脚本: IP=`ifconfig | g

  • PHP获取当前页面完整URL的实现代码

    javascript实现: 复制代码 代码如下: top.location.href   顶级窗口的地址 this.location.href  当前窗口的地址 PHP实现: 复制代码 代码如下: #测试网址:     http://localhost/blog/testurl.php?id=5//获取域名或主机地址 echo $_SERVER['HTTP_HOST']."<br>"; #localhost//获取网页地址 echo $_SERVER['PHP_SELF']

随机推荐