这几天接了个私活,也用到的读取网页的信息,就构造了下面两个类,这个两个类也可以用于SQL注入检查工具这个项目里,所以放这里也刚刚好,注释的我都写了,可是用法我暂时不写了,以后用到就明白了
1、构造了一个web地址类,
2、构造了一个得到页面数据和图片的类
/**/
/// <summary>
/// 页面连接信息类
/// </summary>
public class CWebUrlInfo
... {
private string _WebUrl = "";//地址
/**//// <summary>
/// 地址,包含GET连接数据
/// </summary>
public string WebUrl
...{
get ...{ return _WebUrl; }
set ...{ _WebUrl = value; }
}
private string _Accept = "*/*"; //访问类型,默认*/*
/**//// <summary>
/// 访问类型,默认*/*
/// </summary>
public string Accept
...{
get ...{ return _Accept; }
set ...{ _Accept = value; }
}
private string _RefererUrl = "";//引用地址
/**//// <summary>
/// 引用地址
/// </summary>
public string RefererUrl
...{
get ...{ return _RefererUrl; }
set ...{ _RefererUrl = value; }
}
private string _ContentType = "application/x-www-form-urlencoded";//文件种类
/**//// <summary>
/// 文件种类
/// </summary>
public string ContentType
...{
get ...{ return _ContentType; }
set ...{ _ContentType = value; }
}
private string _UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon)"; //客户端信息,默认IE6
/**//// <summary>
/// 客户端信息,默认IE6
/// </summary>
public string UserAgent
...{
get ...{ return _UserAgent; }
set ...{ _UserAgent = value; }
}
private bool _KeepAlive = true; //是否保持连接状态
/**//// <summary>
/// 是否保持连接状态
/// </summary>
public bool KeepAlive
...{
get ...{ return _KeepAlive; }
set ...{ _KeepAlive = value; }
}
private CookieContainer _CookieContainer = new CookieContainer(); //cookie数据
/**//// <summary>
/// cookie数据
/// </summary>
public CookieContainer CookieContainer
...{
get ...{ return _CookieContainer; }
set ...{ _CookieContainer = value; }
}
private bool _AllowAutoRedirec = false; //是否自动跳转
/**//// <summary>
/// 是否自动跳转
/// </summary>
public bool AllowAutoRedirec
...{
get ...{ return _AllowAutoRedirec; }
set ...{ _AllowAutoRedirec = value; }
}
}
/// 页面连接信息类
/// </summary>
public class CWebUrlInfo
... {
private string _WebUrl = "";//地址
/**//// <summary>
/// 地址,包含GET连接数据
/// </summary>
public string WebUrl
...{
get ...{ return _WebUrl; }
set ...{ _WebUrl = value; }
}
private string _Accept = "*/*"; //访问类型,默认*/*
/**//// <summary>
/// 访问类型,默认*/*
/// </summary>
public string Accept
...{
get ...{ return _Accept; }
set ...{ _Accept = value; }
}
private string _RefererUrl = "";//引用地址
/**//// <summary>
/// 引用地址
/// </summary>
public string RefererUrl
...{
get ...{ return _RefererUrl; }
set ...{ _RefererUrl = value; }
}
private string _ContentType = "application/x-www-form-urlencoded";//文件种类
/**//// <summary>
/// 文件种类
/// </summary>
public string ContentType
...{
get ...{ return _ContentType; }
set ...{ _ContentType = value; }
}
private string _UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon)"; //客户端信息,默认IE6
/**//// <summary>
/// 客户端信息,默认IE6
/// </summary>
public string UserAgent
...{
get ...{ return _UserAgent; }
set ...{ _UserAgent = value; }
}
private bool _KeepAlive = true; //是否保持连接状态
/**//// <summary>
/// 是否保持连接状态
/// </summary>
public bool KeepAlive
...{
get ...{ return _KeepAlive; }
set ...{ _KeepAlive = value; }
}
private CookieContainer _CookieContainer = new CookieContainer(); //cookie数据
/**//// <summary>
/// cookie数据
/// </summary>
public CookieContainer CookieContainer
...{
get ...{ return _CookieContainer; }
set ...{ _CookieContainer = value; }
}
private bool _AllowAutoRedirec = false; //是否自动跳转
/**//// <summary>
/// 是否自动跳转
/// </summary>
public bool AllowAutoRedirec
...{
get ...{ return _AllowAutoRedirec; }
set ...{ _AllowAutoRedirec = value; }
}
}
/**/
/// <summary>
/// 页面连接信息类
/// </summary>
public class CWebUrlInfo
... {
private string _WebUrl = "";//地址
/**//// <summary>
/// 地址,包含GET连接数据
/// </summary>
public string WebUrl
...{
get ...{ return _WebUrl; }
set ...{ _WebUrl = value; }
}
private string _Accept = "*/*"; //访问类型,默认*/*
/**//// <summary>
/// 访问类型,默认*/*
/// </summary>
public string Accept
...{
get ...{ return _Accept; }
set ...{ _Accept = value; }
}
private string _RefererUrl = "";//引用地址
/**//// <summary>
/// 引用地址
/// </summary>
public string RefererUrl
...{
get ...{ return _RefererUrl; }
set ...{ _RefererUrl = value; }
}
private string _ContentType = "application/x-www-form-urlencoded";//文件种类
/**//// <summary>
/// 文件种类
/// </summary>
public string ContentType
...{
get ...{ return _ContentType; }
set ...{ _ContentType = value; }
}
private string _UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon)"; //客户端信息,默认IE6
/**//// <summary>
/// 客户端信息,默认IE6
/// </summary>
public string UserAgent
...{
get ...{ return _UserAgent; }
set ...{ _UserAgent = value; }
}
private bool _KeepAlive = true; //是否保持连接状态
/**//// <summary>
/// 是否保持连接状态
/// </summary>
public bool KeepAlive
...{
get ...{ return _KeepAlive; }
set ...{ _KeepAlive = value; }
}
private CookieContainer _CookieContainer = new CookieContainer(); //cookie数据
/**//// <summary>
/// cookie数据
/// </summary>
public CookieContainer CookieContainer
...{
get ...{ return _CookieContainer; }
set ...{ _CookieContainer = value; }
}
private bool _AllowAutoRedirec = false; //是否自动跳转
/**//// <summary>
/// 是否自动跳转
/// </summary>
public bool AllowAutoRedirec
...{
get ...{ return _AllowAutoRedirec; }
set ...{ _AllowAutoRedirec = value; }
}
}
/// 页面连接信息类
/// </summary>
public class CWebUrlInfo
... {
private string _WebUrl = "";//地址
/**//// <summary>
/// 地址,包含GET连接数据
/// </summary>
public string WebUrl
...{
get ...{ return _WebUrl; }
set ...{ _WebUrl = value; }
}
private string _Accept = "*/*"; //访问类型,默认*/*
/**//// <summary>
/// 访问类型,默认*/*
/// </summary>
public string Accept
...{
get ...{ return _Accept; }
set ...{ _Accept = value; }
}
private string _RefererUrl = "";//引用地址
/**//// <summary>
/// 引用地址
/// </summary>
public string RefererUrl
...{
get ...{ return _RefererUrl; }
set ...{ _RefererUrl = value; }
}
private string _ContentType = "application/x-www-form-urlencoded";//文件种类
/**//// <summary>
/// 文件种类
/// </summary>
public string ContentType
...{
get ...{ return _ContentType; }
set ...{ _ContentType = value; }
}
private string _UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon)"; //客户端信息,默认IE6
/**//// <summary>
/// 客户端信息,默认IE6
/// </summary>
public string UserAgent
...{
get ...{ return _UserAgent; }
set ...{ _UserAgent = value; }
}
private bool _KeepAlive = true; //是否保持连接状态
/**//// <summary>
/// 是否保持连接状态
/// </summary>
public bool KeepAlive
...{
get ...{ return _KeepAlive; }
set ...{ _KeepAlive = value; }
}
private CookieContainer _CookieContainer = new CookieContainer(); //cookie数据
/**//// <summary>
/// cookie数据
/// </summary>
public CookieContainer CookieContainer
...{
get ...{ return _CookieContainer; }
set ...{ _CookieContainer = value; }
}
private bool _AllowAutoRedirec = false; //是否自动跳转
/**//// <summary>
/// 是否自动跳转
/// </summary>
public bool AllowAutoRedirec
...{
get ...{ return _AllowAutoRedirec; }
set ...{ _AllowAutoRedirec = value; }
}
}