[C#] 纯文本查看 复制代码
//创建Httphelper对象
HttpHelper http = new HttpHelper();
//创建Httphelper参数对象
HttpItem item = new HttpItem()
{
URL = "http://www.sufeinet.com",//URL 必需项
Method = "get",//URL 可选项 默认为Get
ContentType = "text/html",//返回类型 可选项有默认值
ResultCookieType = ResultCookieType.CookieContainer
};
//请求的返回值对象
HttpResult result = http.GetHtml(item);
[C#] 纯文本查看 复制代码
// 第二次使用Cookie
//创建Httphelper参数对象
item = new HttpItem()
{
URL = "http://www.sufeinet.com/thread-9989-1-1.html",//URL 必需项
Method = "get",//URL 可选项 默认为Get
ContentType = "text/html",//返回类型 可选项有默认值
CookieContainer = cookie,//把Cookie写入请求串中
ResultCookieType = ResultCookieType.CookieContainer
};
//请求的返回值对象
result = http.GetHtml(item);
//获取Html
string html = result.Html;
[C#] 纯文本查看 复制代码
//创建Httphelper对象
HttpHelper http = new HttpHelper();
//创建Httphelper参数对象
HttpItem item = new HttpItem()
{
URL = "http://www.sufeinet.com",//URL 必需项
Method = "get",//URL 可选项 默认为Get
ContentType = "text/html",//返回类型 可选项有默认值
ResultCookieType = ResultCookieType.CookieContainer
};
//请求的返回值对象
HttpResult result = http.GetHtml(item);
//获取请求的Cookie
CookieContainer cookie =new CookieContainer();
//将返回的CookieCollection转成CookieContainer格式就行了。
cookie.Add(result.CookieCollection);
// 第二次使用Cookie
//创建Httphelper参数对象
item = new HttpItem()
{
URL = "http://www.sufeinet.com/thread-9989-1-1.html",//URL 必需项
Method = "get",//URL 可选项 默认为Get
ContentType = "text/html",//返回类型 可选项有默认值
CookieContainer = cookie,//把Cookie写入请求串中
ResultCookieType = ResultCookieType.CookieContainer
};
//请求的返回值对象
result = http.GetHtml(item);
//获取Html
string html = result.Html;