问题就是在这,我有这思路,但没有具体的操作方法。下面这一句,还是不知道该往哪里放。CookieCollection = cookie,//把Cookie写入请求串中
[C#] 纯文本查看 复制代码 using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CsharpHttpHelper;
using CsharpHttpHelper.Enum;
using System.Net;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//创建Httphelper对象
HttpHelper http = new HttpHelper();
//创建Httphelper参数对象
HttpItem item = new HttpItem()
{
URL = "http://www.510376.com/tools/regcode.php?verify=08login&t=",//URL 必需项
Method = "get",//URL 可选项 默认为Get
ContentType = "text/html",//返回类型 可选项有默认值
ResultCookieType = ResultCookieType.CookieCollection
};
//请求的返回值对象
HttpResult result = http.GetHtml(item);
//获取请求的Cookie
CookieCollection cookie = result.CookieCollection;
}
private void btnOK_Click(object sender, EventArgs e)
{
// 第二次使用Cookie
HttpHelper http = new HttpHelper();
//创建Httphelper参数对象
HttpItem item = new HttpItem()
{
URL = "http://www.510376.com/index.php?/ajax/check_login/username/%E4%BF%A1%E9%98%B3%E8%AF%9A%E4%BF%A1%E4%BA%8C%E6%89%8B%E8%BD%A6/password/a123456/regcode/" + txtCode.Text.Trim() + "/verify/08login/expires/604800/cmslogin/1/datatype/json/domain/www.510376.com&callback=jQuery1102033559174329472374_1532680542340&_=1532680542341",//URL 必需项
Method = "get",//URL 可选项 默认为Get
ContentType = "text/html",//返回类型 可选项有默认值
CookieCollection = cookie,//把Cookie写入请求串中
ResultCookieType = ResultCookieType.CookieCollection
};
//请求的返回值对象
HttpResult result = http.GetHtml(item);
result = http.GetHtml(item);
//获取Html
txtHtml.Text = result.Html;
}
}
}
|