想搞个自动注册邮箱的东东玩玩,所以找到Gmail,结果直接碰了钉子!这里贴出主要代码,大家帮看看,或者谁有现成的代码也行!原来的想法就是通过一个request去请求gmail的注册页面,获取必要的信息,如token、验证图片等信息,然后在将这些信息做为POST的内容再次发送出去。下面是获得信息的方法:
private string contentMsg = "";//content private void GetMsg()
{
...
try
{
HttpWebRequest requestNewGmail = WebRequest.Create(gmailUrl) as HttpWebRequest;
requestNewGmail.CookieContainer = holdCookie;
if (requestNewGmail != null)
{
using (HttpWebResponse getCreatAccountRes = requestNewGmail.GetResponse() as HttpWebResponse)
{
using (StreamReader accountInformReader =
new StreamReader(getCreatAccountRes.GetResponseStream()))
{
string resultText = accountInformReader.ReadToEnd();
//get messages
...
}
}
}
}
catch(Exception ex)
{
string tex = ex.Message;
}
}
private void CreateGmail()
{
try
{
//CreatContent
...
//我将其大致组成如下格式:
String.Format("dsh={0}&ktl={1}&ktf={2}&Email={3}&Passwd={4}"
+ "&PasswdAgain={5}&PersistentCookie={6}&rmShown={7}&nshk={8}&ie5OrAbove={9}"
+ "&loc={10}&newaccounttoken={11}&newaccounturl={12}&newaccounttoken_audio={13}"
+ "&newaccounturl_audio={14}&newaccountcaptcha={15}&privacy_policy_url={16}"
+ "&requested_tos_location={17}&requested_tos_language={18}&served_tos_location={19}"
+ "&served_tos_language={20}&submitbutton={21}",...) byte[] content = Encoding.UTF8.GetBytes(createStr); HttpWebRequest requestNewGmail = WebRequest.Create(gmailUrl) as HttpWebRequest;
requestNewGmail.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
requestNewGmail.KeepAlive = true;
requestNewGmail.ContentLength = content.Length;
requestNewGmail.ContentType = "application/x-www-form-urlencoded";
requestNewGmail.Method = "POST";
requestNewGmail.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)";
using (Stream submitSm = requestNewGmail.GetRequestStream())
{
submitSm.Write(content, 0, content.Length);
} string tst = "";
using (HttpWebResponse createResponse = requestNewGmail.GetResponse() as HttpWebResponse)
{
using (StreamReader stsm = new StreamReader(createResponse.GetResponseStream(), Encoding.Default))
{
tst = stsm.ReadToEnd();//这里获取的页面信息和刚开始几乎一模一样,没有进入到申请成功的页面
}
}
}
catch (Exception ex)
{
string tex = ex.Message;
}
}哪位仁兄能帮帮忙啊,这里先谢了!
private string contentMsg = "";//content private void GetMsg()
{
...
try
{
HttpWebRequest requestNewGmail = WebRequest.Create(gmailUrl) as HttpWebRequest;
requestNewGmail.CookieContainer = holdCookie;
if (requestNewGmail != null)
{
using (HttpWebResponse getCreatAccountRes = requestNewGmail.GetResponse() as HttpWebResponse)
{
using (StreamReader accountInformReader =
new StreamReader(getCreatAccountRes.GetResponseStream()))
{
string resultText = accountInformReader.ReadToEnd();
//get messages
...
}
}
}
}
catch(Exception ex)
{
string tex = ex.Message;
}
}
private void CreateGmail()
{
try
{
//CreatContent
...
//我将其大致组成如下格式:
String.Format("dsh={0}&ktl={1}&ktf={2}&Email={3}&Passwd={4}"
+ "&PasswdAgain={5}&PersistentCookie={6}&rmShown={7}&nshk={8}&ie5OrAbove={9}"
+ "&loc={10}&newaccounttoken={11}&newaccounturl={12}&newaccounttoken_audio={13}"
+ "&newaccounturl_audio={14}&newaccountcaptcha={15}&privacy_policy_url={16}"
+ "&requested_tos_location={17}&requested_tos_language={18}&served_tos_location={19}"
+ "&served_tos_language={20}&submitbutton={21}",...) byte[] content = Encoding.UTF8.GetBytes(createStr); HttpWebRequest requestNewGmail = WebRequest.Create(gmailUrl) as HttpWebRequest;
requestNewGmail.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
requestNewGmail.KeepAlive = true;
requestNewGmail.ContentLength = content.Length;
requestNewGmail.ContentType = "application/x-www-form-urlencoded";
requestNewGmail.Method = "POST";
requestNewGmail.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)";
using (Stream submitSm = requestNewGmail.GetRequestStream())
{
submitSm.Write(content, 0, content.Length);
} string tst = "";
using (HttpWebResponse createResponse = requestNewGmail.GetResponse() as HttpWebResponse)
{
using (StreamReader stsm = new StreamReader(createResponse.GetResponseStream(), Encoding.Default))
{
tst = stsm.ReadToEnd();//这里获取的页面信息和刚开始几乎一模一样,没有进入到申请成功的页面
}
}
}
catch (Exception ex)
{
string tex = ex.Message;
}
}哪位仁兄能帮帮忙啊,这里先谢了!
还有发表帖子的时候,不保存状态,而且将页面直接刷新,导致我编了两次!
哎,CSDN啊,怎么会有这种BUG的!
POST过去有什么用。
同感,我不相信有人连Google验证码都能识别却搞不定自动注册。
没有进入到申请成功的页面当然是因为你post的内容不对,至于为什么不对,我们又不做自动注册的为什么还要去研究?
不懂?!那你们来扯什么淡!
你们俩个是搞程序的?!
你们难道不知道图片验证可以通过OCR、通过矩阵算法来做,HTTP我不熟,所以我无法搞清楚请求时发生了什么!
这点都不知道,还有精力来闲搞,真是垃圾!
说的好,朋友给我提供了一段JAVA的代码,我发现正是Cookie的原因,当然还有HTTP头的一些设置。
本来想把测好的代码发上来,但发现这里的人真TMD扯淡,算了,既然都这么牛,想搞自己想去吧!
Gmail的验证码就被你轻描淡写的OCR、矩阵算法就搞定了,很崇拜
captcha是人工智能的一个体现,http://caca.zoy.org/wiki/PWNtcha里有关于captcha的一些记录。
Google的验证也许是比yahoo的差一点,不过绝对是排在前列的。如果你能搞定的话也不需要在这里发帖了,Google会来挖你的