[C#] 纯文本查看 复制代码 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CsharpHttpHelper;
using CsharpHttpHelper.Enum;
using System.Net;
namespace HttpHelpler_member
{
class Program
{
static void Main(string[] args)
{
//创建Httphelper对象 HttpHelper http = new HttpHelper();
//创建Httphelper参数对象
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://localhost:60080/member/login.php?accesscheck=%2Fmember%2Findex.php",//URL 必需项
Method = "POST",//URL 可选项 默认为Get
Postdata = "username=123456&password=andyto202&Submit=%E7%A2%BA%E5%AE%9A",
Allowautoredirect = true,//是否根据301跳转 可选项
AutoRedirectCookie = true,//是否自动处理Cookie 可选项
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
//ResultCookieType = ResultCookieType.String //默认值可以不写
};
//请求的返回值对象
HttpResult result = http.GetHtml(item);
//获取请求的Cookie
string cookie = result.Cookie;
// 第二次使用Cookie
//创建Httphelper参数对象
item = new HttpItem()
{
URL = "http://localhost:60080/member/index.php",//URL 必需项
Method = "get",//URL 可选项 默认为Get
Allowautoredirect = true,//是否根据301跳转 可选项
AutoRedirectCookie = true,//是否自动处理Cookie 可选项
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
Cookie = cookie,
};
//请求的返回值对象
result = http.GetHtml(item);
//获取Html
string html = result.Html;
Console.WriteLine(html);
Console.Read();
}
}
}
上面是我的程式碼
我是參考這篇
http://www.sufeinet.com/thread-10016-1-1.html
使用2次cookie
但是直接輸出得不到
http://localhost:60080/member/index.php
的結果
只有
http://localhost:60080/member/login.php
的結果
但是如果我在
47行
result = http.GetHtml(item);
設置中斷點去看
是有看到
http://localhost:60080/member/index.php
的結果的
請問怎麼會這樣子呢???
|