[C#] 纯文本查看 复制代码
using CsharpHttpHelper;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WebKit.DOM;
using static AutoPlaceOrder.MONILogin;
namespace AutoPlaceOrder
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public static CookieContainer container = null; //存储验证码cookie
Hashtable param = new Hashtable();//this is for keep post data.
TestCookie sc = new TestCookie();
private void button1_Click(object sender, EventArgs e)
{
WebsiteLogin.getUrl("https://9714035371-ccgj.qq168.ws/login");
}
public static HttpResult _httpResult=new HttpResult();
public static HttpHelper _http = new HttpHelper();
public static string _cookie;
public static HttpItem _httpItem = null;
private void button2_Click(object sender, EventArgs e)
{
_httpItem = new HttpItem
{
URL = "https://9714035371-ccgj.qq168.ws/code",
Referer = "https://9714035371-ccgj.qq168.ws/",
Accept = "image/png, image/svg+xml, image/*;q=0.8, */*;q=0.5",
ResultType = CsharpHttpHelper.Enum.ResultType.Byte
};
_httpResult = _http.GetHtml(_httpItem);
_cookie = _httpResult.Cookie;
if (_httpResult != null && _httpResult.ResultByte != null && _httpResult.ResultByte.Length > 0)
{
var stream = new MemoryStream(_httpResult.ResultByte);
pictureBox1.Image = Image.FromStream(stream);
}
}
private void button3_Click(object sender, EventArgs e)
{
_httpItem = new HttpItem
{
URL = "https://9714035371-ccgj.qq168.ws/login",
Referer = "https://9714035371-ccgj.qq168.ws/",
Accept = "image/png, image/svg+xml, image/*;q=0.8, */*;q=0.5",
ResultType = CsharpHttpHelper.Enum.ResultType.String,
Method = "post",
Postdata = "account=" + textBox_username.Text.Trim() + "&password=" + textBox_password.Text.Trim() + "&code=" + textBox_verify.Text.Trim() + "&type=1",
Cookie = _cookie,
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
};
_httpItem.Header.Add("Accept-Language", "zh-cn");
_httpResult = _http.GetHtml(_httpItem);
_cookie = _httpResult.Cookie;
textBox_note.Text += "\r\n"+_cookie;
//获取302跳转URl
string redirectUrl = _httpResult.RedirectUrl;
_httpItem = new HttpItem()
{
URL = redirectUrl,//URL 必需项
Method = "GET",//URL 可选项 默认为Get
Cookie = _cookie,
};
_httpItem.Header.Add("Accept-Language", "zh-cn");
//请求的返回值对象
_httpResult = _http.GetHtml(_httpItem);
//获取请请求的Html
string html = _httpResult.Html;
//获取请求的Cookie
_cookie = _httpResult.Cookie;
textBox_note.Text += "\r\n" + _cookie;
//获取302跳转URl
redirectUrl = _httpResult.RedirectUrl;
_httpItem = new HttpItem()
{
URL = redirectUrl,//URL 必需项
Method = "GET",//URL 可选项 默认为Get
Cookie = _cookie,
};
_httpItem.Header.Add("Accept-Language", "zh-cn");
//请求的返回值对象
_httpResult = _http.GetHtml(_httpItem);
//获取请请求的Html
html = _httpResult.Html;
//获取请求的Cookie
_cookie = _httpResult.Cookie;
textBox_note.Text += _cookie;
textBox_note.Text += "\r\n" + html;
}
}
}