本帖最后由 Firefly1992 于 2014-7-18 14:10 编辑
前几天有个软件需要大批邮箱,想想可是一个个注册太麻烦了。经过一个星期的研究,写了这个程序,虽然还是很麻烦,不过比起网页上注册已经够方便的了。只需要填写验证码,用户名都不用考虑,直接生成可用的随即字符串。
在此分享给大家,大家看看有什么需要改进的地方可以回复我哦~
ps:没有加入代理服务器,不知道加入后程序运行会不会很慢啊。而且代理服务器怎么测试?如果不能用怎么办?没有接触过这方面的东西,苏大大能给讲一下吗?
本程序基于苏飞的HttpHelper。
在此只贴部分主要代码了。
首次登陆
[C#] 纯文本查看 复制代码 public bool MainPageLoad()
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = Webroot + "?cmd=register.entrance&from=163mail",
Method = "get",
Cookie = this.Cookie,
ContentType = "application/x-www-form-urlencoded",
};
HttpResult result = http.GetHtml(item);
string retMsg = result.Html;
this.Cookie = result.Cookie;
this.Envalue = retMsg.Substring(retMsg.IndexOf("envalue") + 11, 6);
return true;
}
保持会话
[C#] 纯文本查看 复制代码 public bool CreateSSL()
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = String.Format("https://ssl.mail.163.com/regall/unireg/prepare.jsp?sid={0}&sd={1}", this.JsessionID, this.ser_adapter),
Method = "get",
Cookie = this.Cookie,
KeepAlive = true,
ContentType = "application/x-www-form-urlencoded",
};
HttpResult result = http.GetHtml(item);
string retMsg = result.Html;
//返回5个回车
if (retMsg == @"
")
return true;
return false;
}
获取验证码
[C#] 纯文本查看 复制代码 public Image getvCode(bool type)
{
string env = JScript.env(this.Envalue).ToString();
string t = JScript.getTime().ToString();
string Url = Webroot;
if (type)
Url += String.Format("?cmd=register.verifyCode&v=common/verifycode/vc_en&env={0}&t={1}", env, t);
else
Url += String.Format("?cmd=register.verifyCode&v=common/verifycode/vc_zh&vt=grey&env={0}&t={1}", env, t);
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = Url,
Method = "get",
ResultType = ResultType.Byte,
ContentType = "application/x-www-form-urlencoded",
};
HttpResult result = http.GetHtml(item);
Image img = byteArrayToImage(result.ResultByte);
return img;
}
提交数据
[C#] 纯文本查看 复制代码 public string Submit(string password, string vcode)
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = String.Format("https://ssl.mail.163.com/regall/unireg/call.do;jsessionid={0}?cmd=register.start", this.JsessionID),
Method = "POST",
ContentType = "application/x-www-form-urlencoded",
Postdata = String.Format("name={0}&flow=main&uid={0}%40163.com&password={1}&confirmPassword={1}&mobile=&vcode={2}&from=163mail", this.Name, password, vcode),
};
HttpResult result = http.GetHtml(item);
string retMsg = result.Html;
return retMsg;
}
二次验证
[C#] 纯文本查看 复制代码 public string Resume(string code)
{
HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = Webroot + "?cmd=register.resume",
Method = "POST",
ContentType = "application/x-www-form-urlencoded",
Postdata = String.Format("vcode={0}&uid={1}%40163.com&suspendId={2}", ConvertToUtf8(code), this.Name, this.SuspendID),
Cookie = this.Cookie,
};
HttpResult result = http.GetHtml(item);
string retMsg = result.Html;
return retMsg;
}
程序下载地址
重新更正了下载地址,谢谢大家支持。
http://www.sufeinet.com/forum.php?mod=attachment&aid=MzYyMnxkNDRkMmE3ZDg4NDIwODgzMGJmNWYwYzkxNGJkMmQ1YXwxNzMyNDMyMTEz&request=yes&_f=.rar
|