[C#] 纯文本查看 复制代码
namespace creatJDID
{
public partial class Form1 : Form
{
HttpItem itemReg = null;
HttpHelper http = null;
private string uuid = "";
private string name = "";
private string value = "";
public Form1()
{
InitializeComponent();
http = new HttpHelper();
itemReg = new HttpItem();
}
private void button1_Click(object sender, EventArgs e)
{
HttpItem item = new HttpItem()
{
URL = "https://reg.jd.com/reg/person?ReturnUrl=http%3A//www.jd.com/",//URL 必需项
Encoding = null,//编码格式(utf-8,gb2312,gbk) 可选项 默认类会自动识别
Method = "GET",//URL 可选项 默认为Get
IsToLower = false,//得到的HTML代码是否转成小写 可选项默认转小写
Cookie = "",//字符串Cookie 可选项
UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 ",//用户的浏览器类型,版本,操作系统 可选项有默认值
Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",// 可选项有默认值
ContentType = "text/html;charset=GBK",//返回类型 可选项有默认值
Referer = "http://www.jd.com/",//来源URL 可选
Allowautoredirect = true,//是否根据301跳转 可选项
Postdata = "",//Post数据 可选项GET时不需要写
PostDataType = PostDataType.String,//默认为传入String类型,也可以设置PostDataType.Byte传入Byte类型数据
ResultType = ResultType.String,//返回数据类型,是Byte还是String
CookieCollection = new System.Net.CookieCollection(),//可以直接传一个Cookie集合进来
ResultCookieType = ResultCookieType.CookieCollection
};
HttpResult result = http.GetHtml(item);
itemReg.Cookie = result.Cookie;
itemReg.CookieCollection = result.CookieCollection;
if (!checkName("Blue200-gift14", result))
{
MessageBox.Show("此用户已注册!");
return;
}
string pattern1 = "<input type=\"hidden\" name=\"uuid\" id=\"uuid\" value=\"(\\S+?)\"/>";
string pattern2 = "<input type=\"hidden\" name=\"(\\S+?)\" value=\"(\\S+?)\"/>";
Match match1 = Regex.Match(result.Html, pattern1, RegexOptions.IgnoreCase);
Match match2 = Regex.Match(result.Html, pattern2, RegexOptions.IgnoreCase);
uuid = match1.Groups[1].Value;
name = match2.Groups[1].Value;
value = match2.Groups[1].Value;
string findisvalue = result.Html.Substring(result.Html.IndexOf("srcid=reg&is=") + 17, 32);
string time = GetTimeLikeJS().ToString();
string imageUrl = "https://authcode.jd.com/verify/image?a=0&acid=" + uuid + "&";
imageUrl = imageUrl + "uid=" + uuid + "&";
imageUrl = imageUrl + "srcid=" + "reg" + "&";
imageUrl = imageUrl + "is=" + findisvalue + "&";
imageUrl = imageUrl + "yys=" + time;
HttpItem item2 = new HttpItem()
{
URL = imageUrl,//URL 必需项
Encoding = null,//编码格式(utf-8,gb2312,gbk) 可选项 默认类会自动识别
Method = "GET",//URL 可选项 默认为Get
IsToLower = false,//得到的HTML代码是否转成小写 可选项默认转小写
Cookie = result.Cookie,//字符串Cookie 可选项
UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 ",//用户的浏览器类型,版本,操作系统 可选项有默认值
Accept = "image/webp,*/*;q=0.8",// 可选项有默认值
ContentType = "image/jpeg",//返回类型 可选项有默认值
Referer = "https://reg.jd.com/reg/person?ReturnUrl=http%3A//www.jd.com/",//来源URL 可选
Allowautoredirect = true,//是否根据301跳转 可选项
Postdata = "",//Post数据 可选项GET时不需要写
PostDataType = PostDataType.String,//默认为传入String类型,也可以设置PostDataType.Byte传入Byte类型数据
ResultType = ResultType.Byte,//返回数据类型,是Byte还是String
CookieCollection = result.CookieCollection,//可以直接传一个Cookie集合进来
ResultCookieType = ResultCookieType.CookieCollection
};
HttpResult result2 = http.GetHtml(item2);
pictureBox1.Image = byteArrayToImage(result2.ResultByte);
}
private long GetTimeLikeJS()
{
long lLeft = 621355968000000000;
DateTime dt = DateTime.Now;
long Sticks = (dt.Ticks - lLeft) / 10000;
return Sticks;
}
private Image byteArrayToImage(byte[] Bytes)
{
using (MemoryStream ms = new MemoryStream(Bytes))
{
Image outputImg = Image.FromStream(ms);
return outputImg;
}
}
private void button2_Click(object sender, EventArgs e)
{
string userName = "Blue200-gift14";
string pwd = "anny1034";
string authcode = this.textBox1.Text;
string postdata = "regType=person&";
postdata += "uuid=" + uuid + "&";
postdata += "regName=" + userName + "&";
postdata += "schoolid=" + "&";
postdata += "pwd=" + pwd + "&";
postdata += "pwdRepeat=" + pwd + "&";
postdata += "authcode=" + authcode + "&";
postdata += "mobileCode=" + "&";
postdata += name +"=" + value;
Random rdm = new Random();
string randomDouble = rdm.NextDouble().ToString();
itemReg.Host = "reg.jd.com";
//itemReg.URL = "https://reg.jd.com/reg/regService?r=0.5679832081886162&ReturnUrl=http%3A//www.jd.com/";
itemReg.URL = "https://reg.jd.com/reg/regService?r="+randomDouble+"&ReturnUrl=http%3A//www.jd.com/";
itemReg.Accept = "*/*";
itemReg.Referer = "https://reg.jd.com/reg/person?ReturnUrl=http%3A//www.jd.com/";
//itemReg.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
itemReg.Method = "POST";
itemReg.PostDataType = PostDataType.String;
itemReg.Postdata = postdata;
itemReg.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 Safari/537.36";
itemReg.ResultType = ResultType.String;
itemReg.Allowautoredirect = true;
HttpResult result3 = http.GetHtml(itemReg,"1");
string flg = result3.Html.Substring(result3.Html.IndexOf("success")+9,4);
}
private bool checkName(string name, HttpResult result)
{
HttpItem item = new HttpItem()
{
URL = "https://reg.jd.com/validate/isPinEngaged?pin=" + name + "&r=0.5163940236997528",//URL 必需项
Encoding = null,//编码格式(utf-8,gb2312,gbk) 可选项 默认类会自动识别
Method = "GET",//URL 可选项 默认为Get
IsToLower = false,//得到的HTML代码是否转成小写 可选项默认转小写
Cookie = result.Cookie,//字符串Cookie 可选项
UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1700.107 ",//用户的浏览器类型,版本,操作系统 可选项有默认值
Accept = "application/json, text/javascript, */*",// 可选项有默认值
ContentType = "image/jpeg",//返回类型 可选项有默认值
Referer = "https://reg.jd.com/reg/person?ReturnUrl=http%3A//www.jd.com/",//来源URL 可选
Host = "reg.jd.com",
Allowautoredirect = true,//是否根据301跳转 可选项
Postdata = "",//Post数据 可选项GET时不需要写
PostDataType = PostDataType.String,//默认为传入String类型,也可以设置PostDataType.Byte传入Byte类型数据
ResultType = ResultType.Byte,//返回数据类型,是Byte还是String
CookieCollection = result.CookieCollection,//可以直接传一个Cookie集合进来
ResultCookieType = ResultCookieType.CookieCollection
};
HttpResult result2 = http.GetHtml(item);
if (result2.Html.Contains("success"))
{
return true;
}
else
{
return false;
}
}
}
}