我常用Dictionary<string, string>来组Post字串
像这样:
[C#] 纯文本查看 复制代码 var dict = new Dictionary<string, string>
{
{ "id", "user" },
{ "pw", "pw" },
{ "lang", "cs" },
};
var item = new HttpItem()
{
URL = "http://www.website.com",
Method = "POST",
Postdata = string.Join("&", dict.Select(d => HttpHelper.URLEncode(d.Key) + "=" + HttpHelper.URLEncode(d.Value))),
PostDataType = PostDataType.String,
};
var result = (new HttpHelper()).GetHtml(item);
建议可以增加个PostdataDict属性如下:
[C#] 纯文本查看 复制代码 var item = new HttpItem()
{
URL = "http://www.website.com",
Method = "POST",
PostdataDict = new Dictionary<string, string>
{
{ "id", "user" },
{ "pw", "pw" },
{ "lang", "en" },
},
PostDataType = PostDataType.Dictionary,
};
var result = (new HttpHelper()).GetHtml(item); |