URL地址是:
http://www.网址.com/index.php?/ajax/check_login/username/这里是用户名/password/这里是密码/regcode/7034/verify/08login/expires/604800/cmslogin/1/datatype/json/domain/www.网址.com&callback=jQuery110208565981670715967_1532587707493&_=1532587707494
[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 System.IO;
using CsharpHttpHelper.Enum;
using System.Net;
namespace TestDock
{
public partial class frmLogin : Form
{
public frmLogin()
{
InitializeComponent();
DateTime dt = DateTime.Now;
System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
int curTime= (int)(dt - startTime).TotalSeconds;
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.510376.com/tools/regcode.php?verify=08login&t=",
Method = "get",//URL 可选项 默认为Get
};
Image img = http.GetImage(item);
pictureBox1.Image = img;
HttpResult result = http.GetHtml(item);
//获取请求的Cookie
Cookies = result.Cookie;
}
private void btnExit_Click(object sender, EventArgs e) //单击关闭按钮事件
{
Application.Exit();
}
string Cookies = string.Empty;
private void btnOK_Click(object sender, EventArgs e) //点击确定按钮事件
{
string u = txtUser.Text.Trim();
string p = txtPass.Text.Trim();
//万能框架对象
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "http://www.510376.com/index.php?/ajax/check_login/username/这里是用户名/password/这里是密码/regcode/7034/verify/08login/expires/604800/cmslogin/1/datatype/json/domain/www.510376.com&callback=jQuery110208565981670715967_1532587707493&_=1532587707494",//URL 必需项
Method = "GET",//URL 可选项 默认为Get
//Encoding = "System.Text.DBCSCodePageEncoding",//编码格式(utf-8,gb2312,gbk) 可选项 默认类会自动识别
Timeout = 100000,//连接超时时间 可选项默认为100000
ReadWriteTimeout = 30000,//写入Post数据超时时间 可选项默认为30000
IsToLower = false,//得到的HTML代码是否转成小写 可选项默认转小写
//Cookie = cookie,//字符串Cookie 可选项
UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0",//用户的浏览器类型,版本,操作系统 可选项有默认值
Accept = "text/html, application/xhtml+xml, */*",// 可选项有默认值
ContentType = "text/html",//返回类型 可选项有默认值
Referer = "http://www.510376.com/login.php",//来源URL 可选项
Allowautoredirect = false,//是否根据301跳转 可选项
AutoRedirectCookie = false,//是否自动处理Cookie 可选项
ResultType = ResultType.String,//返回数据类型,是Byte还是String
};
MessageBox.Show(txtCode.Text.Trim());
HttpResult result = http.GetHtml(item);
string html = result.Html;
string cookie = result.Cookie;
txtHtml.Text = html ;
}
/// <summary>
/// 字节数组生成图片
/// </summary>
/// <param name="Bytes">字节数组</param>
/// <returns>图片</returns>
private Image byteArrayToImage(byte[] Bytes)
{
MemoryStream ms = new MemoryStream(Bytes);
return Bitmap.FromStream(ms, true);
}
}
}
|