[C#] 纯文本查看 复制代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CsharpHttpHelper;
using System.Net;
using CsharpHttpHelper.Enum;
namespace CsharpHttpHelper_Demo
{
public partial class HttpPost_Demo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//创建Httphelper对象
HttpHelper http = new HttpHelper();
//创建Httphelper参数对象
HttpItem item = new HttpItem()
{
URL = "http://www.sufeinet.com",//URL 必需项
Method = "post",//URL 可选项 默认为Get
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
Postdata = "a=123&c=456&d=789",//Post要发送的数据
};
//请求的返回值对象
HttpResult result = http.GetHtml(item);
//获取请请求的Html
string html = result.Html;
//获取请求的Cookie
string cookie = result.Cookie;
}
}
}
[C#] 纯文本查看 复制代码
private void button1_Click(object sender, EventArgs e)
{
//创建Httphelper对象
HttpHelper http = new HttpHelper();
//创建Httphelper参数对象
HttpItem item = new HttpItem()
{
URL = "http://127.0.0.1/dede/login.php",//URL 必需项
Method = "post",//URL 可选项 默认为Get
Referer = "http://127.0.0.1/dede/login.php?gotopage=%2Fdede%2Findex.php",
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
Postdata = "gotopage=%2Fdede%2Findex.php&dopost=login&adminstyle=newdedecms&userid=admin&pwd=admin&sm1=",//Post要发送的数据
Allowautoredirect = true,
};
//请求的返回值对象
HttpResult result = http.GetHtml(item);
//获取请请求的Html
string html = result.Html;
//获取请求的Cookie
string cookie = result.Cookie;
textBox1.Text = html;
item = new HttpItem()
{
URL = "http://127.0.0.1/dede/index.php",//URL 必需项
Method = "get",//URL 可选项 默认为Get
ContentType = "text/html",//返回类型 可选项有默认值
Cookie=result.Cookie,
Referer = "http://127.0.0.1/dede/login.php",
Allowautoredirect=true,
// ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
};
result=http.GetHtml(item);
textBox2.Text = result.Html;
}
[C#] 纯文本查看 复制代码
private void button1_Click(object sender, EventArgs e)
{
//创建Httphelper对象
HttpHelper http = new HttpHelper();
//创建Httphelper参数对象
HttpItem item = new HttpItem()
{
URL = "http://127.0.0.1/dede/login.php",//URL 必需项
Method = "post",//URL 可选项 默认为Get
Referer = "http://127.0.0.1/dede/login.php?gotopage=%2Fdede%2Findex.php",
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
Postdata = "gotopage=%2Fdede%2Findex.php&dopost=login&adminstyle=newdedecms&userid=admin&pwd=admin&sm1=",//Post要发送的数据
//Allowautoredirect = true,
};
//请求的返回值对象
HttpResult result = http.GetHtml(item);
//获取请请求的Html
string html = result.Html;
//获取请求的Cookie
string cookie = result.Cookie;
cookie = HttpHelper.GetSmallCookie(cookie);
textBox1.Text = cookie;
item = new HttpItem()
{
URL = "http://127.0.0.1/dede/index.php",//URL 必需项
Method = "get",//URL 可选项 默认为Get
ContentType = "text/html",//返回类型 可选项有默认值
Cookie = cookie,
Referer = "http://127.0.0.1/dede/login.php",
Allowautoredirect=true,
// ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
};
result=http.GetHtml(item);
textBox2.Text = result.Html;
}