Ejemplo n.º 1
0
        public void forlog(string cookie,string name,string pwd)
        {
            string url = string.Format("http://reg.email.163.com/unireg/call.do?cmd=register.formLog");
            string[] data =
            {
                string.Format("opt=write_field&flow=main&field=name&result=done&uid={0}%40163.com&timecost={1}&level=info",name,new Random ().Next (4000,10000).ToString () ),
                string.Format ("opt=write_field&flow=main&field=pwd&result=done&strength=2&timecost={0}&level=info",new Random ().Next (4000,10000).ToString ()),
                string.Format ("opt=write_field&flow=main&field=cfmPwd&result=done&timecost={0}&level=info",new Random ().Next (4000,10000).ToString ()),
                string.Format ("opt=write_field&flow=main&field=vcode&result=done&timecost={0}&level=info",new Random ().Next (4000,10000).ToString ()),

             };
            string postdata = "";
            //"opt=write_field&flow=main&field=name&result=done&uid=kljdiel%40163.com&timecost=4460&level=info";
            //opt=write_field&flow=main&field=pwd&result=done&strength=2&timecost=2927&level=info
            //opt=write_field&flow=main&field=cfmPwd&result=done&timecost=2967&level=info
            //opt=write_field&flow=main&field=vcode&result=done&timecost=4920&level=info
            int index = 0;

            while (index < data.Length)
            {
                postdata = data[index];
                index++;

                items = new HttpItems()
                {
                    URL = url,
                    Cookie = Cookies,
                    ProxyIp = Proxy
                };
                hr = helper.GetHtml(items,ref Cookies);
                //Cookies +=  HttpHelpers.GetSmallCookie(hr.Cookie);
                string reHtml = hr.Html.Replace("\r\n", "").Replace("\t", "").Replace("\n", "");
            }
            //reHtml = reHtml.Trim();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 采用httpwebrequest方式访问网络,根据传入的URl地址,得到响应的数据字符串。
        /// </summary>
        /// <param name="objHttpItems">参数列表</param>
        /// <param name="cookie">自动维护的字符串cookie</param>
        /// <returns>HttpResults 为返回结果</returns>
        public HttpResults GetHtml(HttpItems objHttpItems, ref string cookie)
        {
            //调用专门读取数据的类
            HttpResults res = GetHttpRequestData(objHttpItems);

            cookie     = new XJHTTP().UpdateCookie(cookie, res.Cookie);
            res.Cookie = cookie;
            return(res);
        }
Ejemplo n.º 3
0
        private void btnGetWebbrowserCookie_Click(object sender, EventArgs e)
        {
            //只能以字符串方式获得
            XJHTTP xjhttp = new XJHTTP();
            string cookie = xjhttp.GetCookieByWininet("https://www.taobao.com");
            HttpHelpers http = new HttpHelpers();
            HttpItems hi = new HttpItems();
            hi = new HttpItems();

            hi.URL = "http://i.taobao.com/my_taobao.htm?spm=a21bo.7724922.1997525045.1.2gOl9t";
            hi.Cookie = cookie;
            hr = http.GetHtml(hi);
            if (hr.Html.Contains("我的淘宝"))
            {
                MessageBox.Show("登录成功");
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 获取验证码
 /// </summary>
 /// <param name="objHttpItems">参数列表</param>
 /// <returns>Img</returns>
 public Image GetImg(HttpResults hr)
 {
     return byteArrayToImage(hr.ResultByte);
 }
Ejemplo n.º 5
0
        public bool Login163(string user,string pwd)
        {
            Cookies = "";
            string url = "";
            string postdata = "";
            string reHtml = "";
            try
            {
                //获取浏览器标识JESSION等基础信息
                url = string.Format("http://reg.163.com/click.jsp?click_in=Login&v={0}&click_count_spec=userLoginQuery&_ahref=&_at=",new XJHTTP ().GetTimeByJs ());
                items = new HttpItems() {
                    URL =url,
                    Cookie =Cookies,
                    Referer=string.Format ("http://reg.163.com/UserLogin.do?errorType=460&errorUsername={0}@163.com",user )//"http://reg.163.com/UserLogin.do"
                };
                hr = helper.GetHtml(items ,ref Cookies );
                reHtml = hr.Html;

                //提交登录信息
                url = string.Format("https://reg.163.com/logins.jsp");
                postdata = string.Format("type=1&product=urs&url=&url2=http%3A%2F%2Freg.163.com%2FUserLogin.do&username={0}%40163.com&password={1}",user ,pwd );
                items = new HttpItems()
                {
                    URL = url,
                    Cookie = Cookies,
                    Method ="post",
                    Postdata =postdata,
                     Referer = string.Format("http://reg.163.com/UserLogin.do?errorType=460&errorUsername={0}@163.com", user)
                };
                hr = helper.GetHtml(items, ref Cookies);
                reHtml = hr.Html;

                //登录后面内容
                url = string.Format("http://reg.163.com/Main.jsp?username={0}",user );
                items = new HttpItems()
                {
                    URL = url,
                    Cookie = Cookies,
                };
                hr = helper.GetHtml(items, ref Cookies);
                reHtml = hr.Html;

                if (reHtml.Contains("上次登录")) {
                    return true;
                }
            }

            catch (Exception ex)
            {

            }

            return false;
        }
Ejemplo n.º 6
0
        private string[] commandOne(CsdnResouce item, string code = "")
        {
            string[] status = { "模拟评分", "成功/失败", "无验证码", "状态信息", "无附加信息" };
            if (code != "")
            {
                status[2] = "验证码:"+code ;
            }
            hr_com = new HttpHelpers().GetHtml(new HttpItems() {
                URL = "http://download.csdn.net/index.php/comment/get_comment_data/" + item.Id + @"/1?jsonpcallback=jsonp1448000002880&&t=1448000436379",
                Container = cc,
                Referer = item.Url
            } );

            string rehtml = hr_com.Html.Replace("\\r\\n", "").Replace("\\n", "").Replace("\\t", "").Replace(" ", "");
            rehtml = Decode(rehtml);
            Regex regcont=new Regex (@"user_name\\"">(.*?)<\\\/a><\\\/dt><dd>(.*?)<");
            MatchCollection mccont = regcont.Matches(rehtml);
            rehtml = "";
            foreach (Match  m in mccont )
            {
                if (rehtml.Length < m.Groups[2].Value.Length)
                {
                    rehtml = m.Groups[2].Value;
                }
            }
            //getCommandList();
            long epochS = (DateTime.Now.AddSeconds(-5).ToUniversalTime().Ticks - 621355968000000000) / 10000;
            long epochE = (DateTime.Now.ToUniversalTime().Ticks - 621355968000000000) / 10000;
            //Get评论
            int index = ran.Next(comMsg.Length);
            string commentcon=comMsg [index ]+","+rehtml ;
            string url;

            if ("".Equals(code))
            {
                url = string.Format("http://download.csdn.net/index.php/comment/post_comment?jsonpcallback=jsonp{0}&sourceid={1}&content={2}&rating={3}&t={4}", epochS, item.Id, new XJHTTP().UrlEncoding(item.Name + commentcon ), new Random().Next(3, 6), epochE);
            }
            else
            {
                url = string.Format("http://download.csdn.net/index.php/comment/post_comment?jsonpcallback=jsonp{0}&sourceid={1}&content={2}&txt_validcode={3}&rating={4}&t={5}", epochS, item.Id, new XJHTTP().UrlEncoding(item.Name + commentcon), code, new Random().Next(3, 6), epochE);
            }

            string html = new HttpHelpers().GetHtml(new HttpItems() {
                URL =url ,
                Container =cc
            }).Html;

            //评论成功完成
            if (html.Contains("\"succ\":1"))
            {
                JfCount++;
                status[1] = "成功";
                status[3] = "当前积分:" + JfCount.ToString();
                status[4] = item.Name + comMsg[index];
            }
            else
            {
                status[1] = "失败";
                status[3] = "当前积分:" + JfCount.ToString();

                Regex reg = new Regex("msg\":\"(.+?)\"");
                string msg = new XJHTTP().FromUnicodeString(html);
                MatchCollection mc = reg.Matches(msg);
                if (mc.Count > 0)
                {
                    status[4] = mc[0].Groups[1].Value;
                    //item.Msg = mc[0].Groups[1].Value;
                }
                else
                {
                    status[4] = msg;
                    //item.Msg = msg;
                }

                if ((status[4].Contains("请填写验证码") || status[4].Contains("验证码错误")) && getImgVcode != null)
                {
                    string vcode = getcomVcode("http://download.csdn.net/index.php");
                    if (vcode != "")
                    {
                        return commandOne(item, vcode);
                    }
                }
                else if(msg .Contains ("您因违反"))
                {
                    status[4] = msg;
                    Logscomsole(status );
                    this.Clear();
                    return status;
                }

            }
            return status;
        }
Ejemplo n.º 7
0
        private string activeRegEmai1(CookieContainer ccc)
        {
            string reText = "";
            string[] status = { "操作", "成功/失败", "状态信息", "无验证码", "无附加信息" };

            HttpItems item = new HttpItems();
            HttpHelpers heler = new HttpHelpers();
            HttpResults hr = new HttpResults();
            Regex regex = null;
            MatchCollection mc = null;
            int trytimes = 0;

            item = new HttpItems();
            //https://10minutemail.net/
            item.URL = @"http://10minutemail.com/10MinuteMail/index.html";
            item.Method = "Post";
            item.Postdata = @"AJAXREQUEST=j_id3&j_id4=j_id4&javax.faces.ViewState=j_id42162&j_id4%3Apoll=j_id4%3Apoll&";
            item.Container = ccc;
            item.Allowautoredirect = true;
            CHECKEMAIL:
            hr = heler.GetHtml(item);
            string emalurl = hr.Html.Replace("\r\n", "").Replace("\t", "").Replace("\n", "");
            if ("errorerror".Equals(emalurl))
            {
                return "失败:errorerror";
            }
            regex = new Regex("<td>service@register\\.csdn.net</td><td><a href=\".*?\">\\[CSDN\\]");
            mc = regex.Matches(emalurl);

            if (mc.Count == 0)
            {
                if (trytimes <= 10)
                {
                    trytimes++;
                    status[0] = "注册帐号";
                    status[1] = "进行中";
                    status[2] = "等待邮件到达";
                    status[3] = "20秒后重新扫描";
                    status[4] = "";
                    Logscomsole(status);
                    Thread.Sleep(20000);
                    goto CHECKEMAIL;
                }
                else
                {
                    status[0] = "注册帐号";
                    status[1] = "失败";
                    status[2] = "邮件长时间未到";
                    status[3] = "重试申请";
                    status[4] = "";
                    Logscomsole(status);
                    //reg();
                    return "邮件长时间未到";
                }

            }
            if (mc != null && mc.Count >= 1)
            {
                status[0] = "注册帐号";
                status[1] = "进行中";
                status[2] = "扫描到激活邮件";
                status[3] = "即将完成申请";
                status[4] = "";
                Logscomsole(status);

                string urltmp = @"http://10minutemail.com/" + mc[0].Groups[0].Value.Split(new char[] { '\"' })[1].Replace ("&amp;","&");// +"lang=zh-cn";
                //Console.WriteLine(urltmp );
                item = new HttpItems();
                item.URL = urltmp;
                item.Container = ccc;
                item.Allowautoredirect=true;
                hr = heler.GetHtml(item);
                emalurl = hr.Html.Replace("\r\n", "").Replace("\t", "").Replace("\n", "");
                // Console.WriteLine(emalurl);
                //action=userInfoView
                //regex = new Regex("CSDN各项服务。<br/><br/> https(.*?)<br/>");

                regex = new Regex("https://passport.csdn.net(.*?)action=userInfoView");
                mc = regex.Matches(emalurl);
                if (mc != null && mc.Count > 0)
                {
                    string urlacc = mc[0].Groups[0].Value.Replace("&amp;", "&");
                    //string urlacc = mc[0].Groups[0].Value.Split(new char[] { '\"' })[1]; ;
                    item = new HttpItems();
                    item.URL = urlacc;
                    item.Container = new CookieContainer();
                    hr = heler.GetHtml(item);
                    string htmlss = hr.Html;
                    if (htmlss.Contains("注册成功"))
                    {
                        return "注册成功";
                    }
                    else
                    {
                        return "注册失败" + htmlss;
                    }
                }
            }

            return "注册失败";
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <returns></returns>
        public string Login()
        {
            string[] status = { "操作", "成功/失败", "状态信息", "无验证码", "无附加信息" };

            if (User == "" || Pass == "")
            {
                Logscomsole(new string[] { "模拟登录", "失败", "帐号或者密码有误", "", "" });
                return "";
            }
            //Logscomsole(status);

            string reText = "";
            string url = "https://passport.csdn.net/account/login";//请求地址
            string loginUrl = "https://passport.csdn.net/account/login";
            reText = string.Empty;//请求结果,请求类型不是图片时有效
            hr_down = new HttpHelpers ().GetHtml(new HttpItems() {
                URL=url ,
                Container =cc
            });//发起请求并得到结果
            reText = hr_down.Html;//得到请求结果
            if (!string.IsNullOrEmpty(reText) && !reText.Equals("请求被中止: 连接被意外关闭。"))
            {

                //内部变量
                string lt = string.Empty, execution = string.Empty, eventId = string.Empty;
                //匹配必须参数

                Regex reg = new Regex("userId\":(.*?),\"isLocked\"");
                MatchCollection mc = reg.Matches(reText);
                if (mc.Count > 0)
                {
                    return "已登录成功";
                }
                 reg = new Regex("name=\"lt\" value=\"(.+?)\"");
                 mc = reg.Matches(reText);
                //(name=\"lt\" value=\"(.+?)\")|
                 if (mc.Count == 0)
                 {
                     return reText;
                 }
                lt = mc[0].Groups[1].Value;
                //-execution-
                MatchCollection mc2 = new Regex ("name=\"execution\" value=\"(.+?)\"").Matches(reText);
                execution = mc2[0].Groups[1].Value;
                //-eventId-
                MatchCollection mc3 = new Regex("name=\"_eventId\" value=\"(.+?)\"").Matches(reText);
                eventId = mc3[0].Groups[1].Value;

                hr_down = new HttpHelpers().GetHtml(new HttpItems()
                {
                    URL = loginUrl,
                    Container = cc,
                    Method = "post",
                    Postdata = string.Format("username={0}&password={1}&lt={2}&execution={3}&_eventId={4}", user, pass, lt, execution, eventId)
                });

                reText = hr_down.Html;
                //检查是否登录成功
                Regex regerro = new Regex("<span id=\"error-message\">(.+?)</span>");
                MatchCollection mcerro = regerro.Matches(reText);
                //错误数大于0
                if (mcerro.Count > 0)
                {
                    reText = mcerro[0].Groups[1].Value;
                    Logscomsole(new string[] { "模拟登录", "失败", reText, "", "" });
                    isonline = false;
                }
                else
                {
                    if (reText.Contains("redirect_back") && reText.Contains("loginapi.js"))
                    {
                        reText = reText.Replace("\r\n", "").Replace("\n", "").Replace("\t", "");
                        NickName = getPater(reText, "var data = {", "};", new char[] { ',' }, new char[] { ':', '\"' })["nickName"];
                        reText = "登录成功";
                        Logscomsole(new string[] { "模拟登录","成功", "昵称:" + NickName ,"",""});
                        isonline = true;
                    }
                    else
                    {
                        reText = "登录失败,账号已失效!";
                        Logscomsole(new string[] { "模拟登录","失败",reText ,"","" });
                        isonline = false;
                    }
                }
            }

            return reText;
        }
Ejemplo n.º 9
0
        private void btnGet_Click(object sender, EventArgs e)
        {
            Random r = new Random();
            //初始化Cookie变量
            cc = new System.Net.CookieContainer();
            item = new HttpItems();
            //get 主页
            item.URL = "http://www.mp4ba.com";
            item.Cookie = "__cfduid=123456789; search_state=1463675467;";
            item.UseUnsafe = true;
            hr = http.GetHtml(item);

            string cookie = hr.Cookie;
            XJHTTP xjhttp = new XJHTTP();
            cc = xjhttp.AddCookieToContainer(cc, cookie);
            //get 验证码
            picurl += r.NextDouble();
            item.URL = picurl;
            item.Referer = BaseUrl;
            item.ResultType = ResultType.Byte; //设置返回值类型
            hr = http.GetHtml(item);

            pic.Image = http.GetImg(hr);
        }
Ejemplo n.º 10
0
        private void Post_AsyncCallBack(HttpResults hrt)
        {
            if (!string.IsNullOrEmpty(hrt.Html))
            {

            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 结果回调方法
 /// </summary>
 /// <param name="result">请求结果对象</param>
 void GetCallBack(HttpResults result)
 {
     MessageBox.Show(result.Html);
 }
Ejemplo n.º 12
0
 private void button8_Click(object sender, EventArgs e)
 {
     XJHTTP xj = new XJHTTP();
     item = new HttpItems();
     item.URL = "www.msdn5.com";
     hr = http.GetHtml(item);
     DateTime dt = xj.GetServerTime(hr);  //返回正常格式的时间
     //例如 Date:Sat, 14 Nov 2015 15:55:35 GMT   返回为正常的 2015-11-15 00:21:19 格式
 }
Ejemplo n.º 13
0
        private void button6_Click(object sender, EventArgs e)
        {
            CookieContainer cc = new CookieContainer();
            HttpItems items = new HttpItems();
            HttpHelpers helper = new HttpHelpers();
            HttpResults hr = new HttpResults();

            string cookie = "";//字符串方式处理
            items = new HttpItems();
            //items.Container = cc; 自动处理方式
            items.Cookie = cookie;
            items.URL = "http://www.u193.com/opt.php?do=login";
            items.Referer = "http://mrtx.u193.com/";
            items.Method = "Post";
            items.Postdata = "username=ceshiyixia1&password=111111";
            items.Allowautoredirect = true;
            hr = helper.GetHtml(items);

            #region 手动处理字符串Cookie方式
            //hr.Cookie调用时会自动清理cookie 自动剔除无用信息.等同于
            // new XJHTTP().ClearCookie(hr.Cookie);
            cookie = new XJHTTP().UpdateCookie(cookie, hr.Cookie);//手动合并两个Cookie
            #endregion

            #region 自动处理字符串Cookie方式
            //使用ref将cookie传递进方法,每次会自动合并上次与本次返回的cookie
            hr = helper.GetHtml(items, ref cookie);

            #endregion
            //第二次请求
            items = new HttpItems();
            items.URL = "http://mrtx.u193.com/";
            items.Referer = "http://mrtx.u193.com/";
            items.Cookie = cookie;
            //  items.Container = cc; 当cc无法被携带提交失败时使用字符串方式即可
            hr = helper.GetHtml(items);
        }
Ejemplo n.º 14
0
        private void button10_Click(object sender, EventArgs e)
        {
            //只返回数据头,不返回结果
            item = new HttpItems();
            item.URL = "www.msdn5.com";
            item.ResultType = ResultType.So;//设置返回结果为急速请求
            hr = http.GetHtml(item);
            //枚举的方式判断
            if (hr.StatusCode == HttpStatusCode.OK)
            {
                MessageBox.Show("请求成功");

            }
            //或 数字形式  HttpCode 2.4 后支持
            if (hr.StatusCodeNum == 200)
            {
                MessageBox.Show("请求成功");

            }
        }
Ejemplo n.º 15
0
        private string[] getCommandList()
        {
            listConSource = new List<CsdnResouce>();
            string[] status = { "获取评分列表", "成功/失败", "状态信息", "无验证码", "无附加信息" };
            //status[1] = "结束";
            status[2] = "执行完毕";
            status[3] = "";
            status[4] = "";
               // Logscomsole(status);

            PreComCount = 0;
            CanComCount = 0;

            //我的下载资源页的资源列表
            hr_com = new HttpHelpers().GetHtml(new HttpItems() {
                URL = "http://download.csdn.net/my/downloads",
                Container = cc
            });
            string DownHtml = hr_com.Html.Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace(" ", "");
            string result = Regex.Replace(DownHtml, @"<!--(.+?)-->", "");
            //获取下载资源数量
            Regex regDown = new Regex("下载资源:<spanclass=\"red\">(.+?)</span>");
            MatchCollection mcDown = regDown.Matches(result);
             DowCount = 0;
            if (mcDown.Count > 0)
            {
                DowCount = Convert.ToDouble(mcDown[0].Groups[1].Value);
            }
            status[1] = "成功";
            status[2] = "下载数:"+DowCount .ToString ();
            //获取剩余积分
            Regex regJf = new Regex("<em>积分:(.+?)</em>");
            MatchCollection mcJf = regJf.Matches(result);
            if (mcJf.Count > 0)
            {
                int.TryParse(mcJf[0].Groups[1].Value, out jfCount);
            }

            status[3] = "积分数:"+jfCount .ToString ();

            //加载数据,Csdn是6个一页
            double Ys = Math.Ceiling(DowCount / 6);

            //10页以上用多线程
            if (Ys > 50)
            {
                //LoadList(DowCount, Ys);
                int threadCount = 5;
                int cnum = (int)Ys / (threadCount - 1);
                //int ynum = (int)Ys % (threadCount - 1);

                var waits = new List<EventWaitHandle>();
                for (int i = 0; i < threadCount-1; i++)
                {
                    int s = 1 + i * cnum;
                    int e = cnum + cnum * i;
                    if (e > Ys)
                    {
                        e = (int)Ys;
                    }
                    //int e=(((cnum +cnum *i)> DowCount )? (int )DowCount:(cnum +cnum *i)) ;

                    var handler = new ManualResetEvent(false);
                    waits.Add(handler);
                    new Thread(new ParameterizedThreadStart(threadForScan))
                        .Start(new Tuple<int[], EventWaitHandle>(new int[] { s, e }, handler));
                }
                WaitHandle.WaitAll(waits.ToArray());
                status[2] = "下载数:" + DowCount.ToString();
                status[3] = "积分数:" + jfCount.ToString();
                status[4] = "共 " + CanComCount.ToString() + " 条可评分记录," + PreComCount.ToString() + " 条10分钟以内记录";
                return status;
            }
            else
            {
                for (int i = 1; i <= Ys; i++)
                {
                    hr_com = new HttpHelpers().GetHtml(new HttpItems() {

                        URL = "http://download.csdn.net/my/downloads/" + i,
                        Container = cc
                    });
                    string Down2Html = hr_com.Html.Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace(" ", "");
                    string result2 = Regex.Replace(Down2Html, @"<!--(.+?)-->", "");
                    //SetList(result2);
                    //获取资源列表
                    Regex reg = new Regex("<dt><divclass=\"icon\"><imgsrc=\"(.+?)\"title=\"(.+?)\"></div><divclass=\"btns\">(.+?)</div><h3><ahref=\"(.+?)\">(.+?)</a><spanclass=\"points\">(.+?)</span></h3></dt>");
                    MatchCollection mc = reg.Matches(result2);
                    if (mc.Count > 0)
                    {
                        foreach (Match item in mc)
                        {
                            CsdnResouce cdsr = new CsdnResouce();

                            Regex regCState = new Regex("<(.+?)>(.+?)</(.+?)>");
                            MatchCollection mcCState = regCState.Matches(item.Groups[3].Value);
                            string sta = mcCState[0].Groups[2].Value;
                            if (sta.Contains("已评价") || sta.Contains("资源已删除"))
                            {
                                continue;
                            }
                            if (!sta.Contains("立即评价"))
                            {
                                PreComCount++;
                                continue;
                            }
                            CanComCount++;
                            String strt = item.Groups[4].Value;
                            cdsr.Url = strt.Substring(0, strt.IndexOf("\""));
                            cdsr.Name = item.Groups[5].Value;
                            cdsr.Point = item.Groups[6].Value;
                            string[] ids = cdsr.Url.Split('/');
                            cdsr.Id = ids[ids.Length - 1];
                            listConSource.Add(cdsr);
                        }
                    }
                    //status[1] = "结束";
                    //status[2] = "执行完毕";
                    //status[3] = "";
                    status[2] = "已完成扫描 " + i.ToString() + "/" + Ys.ToString();
                    status[3] = "";
                    //Logscomsole(status);
                }
                status[2] = "下载数:" + DowCount.ToString();
                status[3] = "积分数:" + jfCount.ToString();
                status[4] = "共 " + CanComCount.ToString() + " 条可评分记录," + PreComCount.ToString() + " 条10分钟以内记录";
                return status;
            }
            //Logscomsole("获取可评分列表", "结束", "获取到 " + CanComCount.ToString() + " 条可评分记录, " + PreComCount.ToString() + " 条10分钟以内记录");
        }
Ejemplo n.º 16
0
 /// <summary>
 /// 帐号是否被锁定
 /// </summary>
 public string GetStatus()
 {
     //http://u.download.csdn.net/upload
     //您因违反CSDN下载频道规则而被锁定帐户
     hr_down = new HttpHelpers().GetHtml(new HttpItems()
     {
         URL = "http://u.download.csdn.net/upload",
         Container = cc
     });
     string rehtml = hr_down.Html.Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace(" ", "");
     if (rehtml.Contains("您因违反CSDN下载频道规则而被锁定帐户"))
     {
         Logscomsole(new string[]  { "检查状态", "失败喽,锁定了", rehtml, "", "" } );
         return "锁定";
     }else
     {
         Logscomsole(new string[] { "检查状态", "成功,尚未", rehtml, "", "" });
         return "正常";
     }
 }
Ejemplo n.º 17
0
        private string getcomVcode(string referurl)
        {
            string[] status = { "模拟下载", "成功/失败", "状态信息", "无验证码", "无附加信息" };
            status[0] = "模拟下载";
            status[1] = "";
            status[2] = "";
            status[3] = "";
            status[4] = "";
            //Logscomsole(status);

            int tryTime = 0;
            string code = "";
            string res = "";
            byte [] imgbyte=null ;
            while (tryTime < 5)
            {
                tryTime++;

                hr_com = new HttpHelpers().GetHtml(new HttpItems()
                {

                    URL = @"http://download.csdn.net/index.php/rest/tools/validcode/comment_validate/10.1749821768607" + new Random().Next().ToString(),
                    Referer = referurl,
                    Container = this.cc,
                    ResultType = ResultType.Byte,

                });
                imgbyte =hr_com.ResultByte;
                code = getImgVcode(imgbyte );
                if (code == "")
                {
                    continue;
                }
                res = new HttpHelpers().GetHtml(new HttpItems()
                {
                    URL = @"http://download.csdn.net/index.php/comment/check_validcode/" + code,
                    Referer = referurl,
                    Container = cc
                }).Html;
                if (res != "验证码错误")
                {
                    return code;
                }
                //File.WriteAllBytes(System.Environment.CurrentDirectory + @"\Codes\" + imgbyte.Length.ToString() + "_" + code + ".bmp", imgbyte);
            }
            Logscomsole(new string[] { "识别评分验证码", "失败", "次数:" + tryTime.ToString(),"","" });
            //Logscomsole("识别评分验证码", "失败", "次数:" + tryTime.ToString());
            return "";
        }
Ejemplo n.º 18
0
        /// <summary>
        /// .net
        /// </summary>
        /// <param name="ccc"></param>
        /// <returns></returns>
        private string activeRegEmai(CookieContainer ccc)
        {
            string reText = "";
            string[] status = { "操作", "成功/失败", "状态信息", "无验证码", "无附加信息" };

            HttpItems item = new HttpItems();
            HttpHelpers heler = new HttpHelpers();
            HttpResults hr = new HttpResults();
            Regex regex = null ;
            MatchCollection mc = null;
            int trytimes = 0;

            item = new HttpItems();
            //https://10minutemail.net/
            item.URL = @"https://10minutemail.net/mailbox.ajax.php?_=";

            item.Container = ccc ;
             CHECKEMAIL:
            hr = heler.GetHtml(item);
            string emalurl = hr.Html.Replace("\r\n", "").Replace("\t", "").Replace("\n", "");
            if ("errorerror".Equals(emalurl))
            {
                return "失败:errorerror";
            }
            regex = new Regex("<td>service@register\\.csdn.net</td><td><a href=\".*?\">\\[CSDN\\]");
            mc = regex.Matches(emalurl);

            if (mc.Count == 0)
            {
                if (trytimes <= 10)
                {
                    trytimes++;
                    status[0] = "注册帐号";
                    status[1] = "进行中";
                    status[2] = "等待邮件到达";
                    status[3] = "20秒后重新扫描";
                    status[4] = "";
                    Logscomsole(status);
                    Thread.Sleep(20000);
                    goto CHECKEMAIL;
                }
                else
                {
                    status[0] = "注册帐号";
                    status[1] = "失败";
                    status[2] = "邮件长时间未到";
                    status[3] = "重试申请";
                    status[4] = "";
                    Logscomsole(status);
                    //reg();
                    return "邮件长时间未到";
                }

            }
            if (mc != null && mc.Count >= 1)
            {
                status[0] = "注册帐号";
                status[1] = "进行中";
                status[2] = "扫描到激活邮件";
                status[3] = "即将完成申请";
                status[4] = "";
                Logscomsole(status);

                string urltmp = @"https://10minutemail.net/" + mc[0].Groups[0].Value.Split(new char[] { '\"' })[1];// +"lang=zh-cn";
                //Console.WriteLine(urltmp );
                item = new HttpItems();
                item.URL = urltmp;
                item.Container =ccc ;
                hr  = heler .GetHtml(item);
                emalurl = hr.Html.Replace("\r\n", "").Replace("\t", "").Replace("\n", "");
                // Console.WriteLine(emalurl);
                regex = new Regex("href=\".*?\"");
                mc = regex.Matches(emalurl);
                if (mc != null && mc.Count > 0)
                {
                    string urlacc = mc[103].Groups[0].Value.Split(new char[] { '\"' })[1].Replace("&amp;", "&"); ;
                    item = new HttpItems();
                    item.URL = urlacc;
                    item.Container = new CookieContainer ();
                    hr = heler.GetHtml(item);
                    string htmlss = hr.Html;
                    if (htmlss.Contains("注册成功"))
                    {
                        return "注册成功";
                    }
                    else
                    {
                        return "注册失败"+htmlss;
                    }
                }
            }

            return "注册失败" ;
        }
Ejemplo n.º 19
0
        private bool getInfo()
        {
            hr_com = new HttpHelpers().GetHtml(new HttpItems()
            {
                URL = "http://download.csdn.net/my/downloads",
                Container = cc
            });

            string DownHtml = hr_com.Html.Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace(" ", "");
            string result = Regex.Replace(DownHtml, @"<!--(.+?)-->", "");
            //获取下载资源数量
            Regex regDown = new Regex("下载资源:<spanclass=\"red\">(.+?)</span>");
            MatchCollection mcDown = regDown.Matches(result);
             DowCount = 0;
            if (mcDown.Count > 0)
            {
                DowCount = Convert.ToDouble(mcDown[0].Groups[1].Value);
            }
            Regex regJf = new Regex("<em>积分:(.+?)</em>");
            MatchCollection mcJf = regJf.Matches(result);
            if (mcJf.Count > 0)
            {
               return  int.TryParse(mcJf[0].Groups[1].Value, out jfCount);
            }
            return false;
        }
Ejemplo n.º 20
0
        private string activeRegEmai2(string emailname,CookieContainer ccc)
        {
            string reText = "";
            string[] status = { "操作", "成功/失败", "状态信息", "无验证码", "无附加信息" };
            Thread.Sleep(15000);
            HttpItems item = new HttpItems();
            HttpHelpers heler = new HttpHelpers();
            HttpResults hr = new HttpResults();
            Regex regex = null;
            MatchCollection mc = null;
            int trytimes = 0;
            string emalid="";
            emalid = emailname .Substring (0,emailname .IndexOf ('@'));
            item = new HttpItems();
            //https://10minutemail.net/
            item.URL = @"http://mailcatch.com/en/rpc.lua";
            item.Method = "Post";
            item.Postdata = string.Format("mod=ListMailsRPC&fct=List&json=%7B%22box%22%3A%22{0}%3Dmailcatch.com%22%2C%22anim%22%3Atrue%7D",emalid );//@"AJAXREQUEST=j_id3&j_id4=j_id4&javax.faces.ViewState=j_id42162&j_id4%3Apoll=j_id4%3Apoll&";
            item.Container = ccc;
            item.Allowautoredirect = true;
            hr = heler.GetHtml(item);
            string emalurl = hr.Html.Replace("\r\n", "").Replace("\t", "").Replace("\n", "");
            if ("errorerror".Equals(emalurl))
            {
                return "失败:errorerror";
            }
            //?box=$boxid&show=a134fc9d-5412-4cda-ac7e-04b48103f78f\">[CSDN

            regex = new Regex("\\&show=(.*?)\\\"\\>\\[CSDN");
            mc = regex.Matches(emalurl);
            if (mc != null && mc.Count >= 1)
            {
                status[0] = "注册帐号";
                status[1] = "进行中";
                status[2] = "扫描到激活邮件";
                status[3] = "即将完成申请";
                status[4] = "";
                Logscomsole(status);
                string []strtmp=mc[0].Groups[0].Value.Split(new char[] { '\"','\\' });
                string urltmp = string.Format("http://yourinbox.mailcatch.com/en/temporary-inbox?box={0}=mailcatch.com{1}", emalid, strtmp[0]);// +"lang=zh-cn";
                //Console.WriteLine(urltmp );
                item = new HttpItems();
                item.URL = urltmp;
                item.Container = ccc;
                item.Allowautoredirect = true;
                hr = heler.GetHtml(item);
                emalurl = hr.Html.Replace("\r\n", "").Replace("\t", "").Replace("\n", "");

                regex = new Regex("https://passport.csdn.net(.*?)action=userInfoView");
                mc = regex.Matches(emalurl);
                if (mc != null && mc.Count > 0)
                {
                    string urlacc = mc[0].Groups[0].Value.Replace("&amp;", "&");
                    return urlacc;
                    //string urlacc = mc[0].Groups[0].Value.Split(new char[] { '\"' })[1]; ;
                    item = new HttpItems();
                    item.URL = urlacc;
                    item.Container = new CookieContainer();
                    hr = heler.GetHtml(item);
                    string htmlss = hr.Html;
                    if (htmlss.Contains("注册成功"))
                    {
                        return "注册成功";
                    }
                    else
                    {
                        return "注册失败" + htmlss;
                    }
                }
            }

            return "注册失败";
        }
Ejemplo n.º 21
0
        /// <summary>
        /// .net
        /// </summary>
        /// <param name="ccc"></param>
        /// <returns></returns>
        private string getRegEmail(CookieContainer ccc)
        {
            HttpItems item = new HttpItems();
            HttpHelpers heler = new HttpHelpers();
            HttpResults hr = new HttpResults();
            string url;

            url = @"https://10minutemail.net/";
            item = new HttpItems()
            {
                URL = url ,
                Container =ccc
            };
            hr = heler.GetHtml(item);
            Regex regex = new Regex("ata-clipboard-text=\".*?\"");
            MatchCollection mc = regex.Matches(hr.Html.Replace("\r\n", "").Replace("\t", "").Replace("\n", ""));
            if (mc != null && mc.Count > 0)
            {

                string email = mc[0].Groups[0].Value;
                email = email.Split(new char[] { '\\', '\"' })[1];
                return email;
            }

            return "";
        }
Ejemplo n.º 22
0
        private string[] downloadOne(CsdnResouce cdrs)
        {
            string[] status = { "模拟下载", "成功/失败", "无验证码", "状态信息", "无附加信息" };
            //if (code != "")
            //{
            //    status[3] = "验证码:" + code;
            //}
            status[0] = "模拟下载";
            status[1] = "";
            status[2] = "";
            status[3] = "";
            status[4] = "";
            //Logscomsole(status);
            string url = cdrs.Tag.ToString().Replace("detail", "download");
            string res = new HttpHelpers().GetHtml(new HttpItems()
            {
                URL = url ,
                Container = cc
            }).Html;

            string taskName = "";
            string regexCode = "<meta name=\"description\" content=\"(.*?)\" />";
            Regex reg = new Regex(regexCode);
            taskName = reg.Match(res).Groups[1].Value;
            regexCode = "action=\"(http://download.csdn.net/index.php/source/do_download/(.*?))\"";
            reg = new Regex(regexCode);
            if (reg.IsMatch(res))
            {
                string durl = reg.Match(res).Groups[1].Value;
                // cdrs .Durl = durl;//下载地址
                bool first = true;
                hr_down = new HttpHelpers().GetHtml(new HttpItems()
                {
                    URL = durl,
                    Referer = url,
                    Method = "Post",
                    Container = cc,
                    Allowautoredirect = true,
                    Postdata = "ds=&validate_code=&basic%5Breal_name%5D=&basic%5Bmobile%5D=&basic%5Bemail%5D=&basic%5Bjob%5D=&basic%5Bcompany%5D=&basic%5Bprovince%5D=&basic%5Bcity%5D=&basic%5Bindustry%5D="
                });
                res = hr_down.Html;
            TRUEDOWNLOAD:
                if (res.Contains("您因违反"))
                {
                    status[0] = "模拟下载";
                    status[1] = "失败";
                    status[2] = res ;
                    status[3] = "";
                    status[4] = "";
                    Logscomsole(status );
                    this.Clear();
                    return status;
                }
                if (res != "<script>document.domain='csdn.net';parent.show_validate_pop();</script>")
                {           //模拟点击下载
                    if (saveFile && !string.IsNullOrEmpty(savePath))
                    {

                        if (!Directory.Exists(SavePath))
                        {
                            Directory.CreateDirectory(SavePath);
                        }
                        //href='http://dldx.csdn.net/fd.php?i=391492108198497&s=c936639a4ad2171ef2bee9ae9e706700';

                        try
                        {
                            hr_down = new HttpHelpers().GetHtml(new HttpItems()
                            {
                                URL = res.Substring(res.IndexOf("http"), res.LastIndexOf('\'') - res.IndexOf("http")),
                                Referer = durl,
                                Container = cc,
                                ResultType = ResultType.Byte,
                                Allowautoredirect = true
                            });
                            //hr.ResultByte;  真实文件内容
                            byte[] bty = hr_down.ResultByte;
                            string a = hr_down.Header.Get("Content-Disposition");
                            a = a.Substring(a.LastIndexOf('\'') + 1);
                            a = HttpUtility.UrlDecode(a, Encoding.UTF8);
                            //a = Encoding.Default.GetString(Encoding.UTF8.GetBytes (a));
                            //a = Encoding.UTF8.GetString(Encoding .UTF8 .GetBytes (a) );
                            cdrs.Log = a;
                            cdrs.Msg = "已保存";
                            File.WriteAllBytes(SavePath + @"\" + a, bty);
                        }
                        catch (Exception ex)
                        {

                            cdrs.Msg = "保存失败:" + ex.Message;
                        }

                    }
                    status[0] = "模拟下载";
                    status[1] = "成功";
                    status[3] = string.IsNullOrEmpty (cdrs.Name )?"":cdrs .Name ;
                    status[2] = first ?"无验证码":"已智能识别验证码";
                    status[4] = "";
                    //cdrs.Rel = "成功";
                    //cdrs.Msg = res==""?"":"验证码:"+res ;
                    //Logscomsole("", "", "", cdrs);
                    return status ;
                }
                else
                {
                    if (first && getImgVcode != null)
                    {
                        res = getdownVcodeUrl(durl, url);
                        first = false;
                        goto TRUEDOWNLOAD;
                    }
                    status[0] = "模拟下载";
                    status[1] = "失败";
                    status[2] = "多次识别错误或者验证码识别接口出错";
                    status[3] = "";
                    status[4] = "";
                }

            }
            else
            {
                status[0] = "模拟下载";
                status[1] = "失败";
                status[2] = "获取下载地址失败";
                status[3] = "";
                status[4] = "";
                //Logscomsole(status);
                //cdrs.Rel = "失败";
                //cdrs.Msg = "获取下载抵制失败";
            }

            //Logscomsole("", "", "", cdrs);
            return status ;
        }
Ejemplo n.º 23
0
        private string getRegEmail2(CookieContainer ccc)
        {
            HttpItems item = new HttpItems();
            HttpHelpers heler = new HttpHelpers();
            HttpResults hr = new HttpResults();

            item = new HttpItems();
            //http://10minutemail.com/10MinuteMail/index.html
            item.URL = @"http://mailcatch.com/en/disposable-email";
            item.Container = ccc;

            hr = heler.GetHtml(item);
            Regex regex = new Regex("ata-clipboard-text=\".*?\"");
            MatchCollection mc = regex.Matches(hr.Html.Replace("\r\n", "").Replace("\t", "").Replace("\n", ""));
            if (mc != null && mc.Count > 0)
            {

                string email = mc[0].Groups[0].Value;
                email = email.Split(new char[] { '\\', '\"' })[1];
                return email;
            }

            return "";
        }
Ejemplo n.º 24
0
        public bool RegUserPass_Music(string user, string pass, ref string status)
        {
            try
            {
                //http://reg.email.163.com/unireg/call.do?cmd=register.entrance&from=163navi%C2%AEPage=163

                //https://ssl.mail.163.com/regall/unireg/prepare.jsp?sid=13B5821160ADE399CD009F3F9AB10EBE&sd=INTERNAL19
                //sid是Cookie中的JSESSIONID

                //验证码
                //http://reg.email.163.com/unireg/call.do?cmd=register.verifyCode&v=common/verifycode/vc_en&env=704864408122&t=1448764801723
                //checkName
                //http://reg.email.163.com/unireg/call.do?cmd=urs.checkName
                //Post
                //name=yqmacmusic

                //https://ssl.mail.163.com/regall/unireg/call.do;jsessionid=13B5821160ADE399CD009F3F9AB10EBE?cmd=register.start
                //name=yqmacmusic&flow=main&uid=yqmacmusic%40163.com&password=yqmacmusic163&confirmPassword=yqmacmusic163&mobile=&vcode=yxysy&from=163navi%C2%AEPage%3D163

                /*name:yqmacmusic
                flow:main
                uid:[email protected]
                password:yqmacmusic163
                confirmPassword:yqmacmusic163
                mobile:
                vcode: yxysy
                from:163navi®Page = 163
              */

                string postData = string.Empty;
                string Vcode = string.Empty;
                byte[] codebytes = null;
                Cookies = "";
                status = string.Empty;
                string cookieForPost = "";
                Cookies = "";
                //获取初始 JSESSIONID,SID两个唯一标识,返回的Cookie里面
                string url = string.Format("http://reg.email.163.com/unireg/call.do?cmd=register.entrance&from=163navi%C2%AEPage=163");
                items = new HttpItems()
                {
                    URL = url,
                    Cookie = Cookies,
                    ProxyIp = Proxy
                };
                hr = helper.GetHtml(items,ref Cookies);
                string reHtml = hr.Html.Replace("\r\n", "").Replace("\t", "").Replace("\n", "");
                if(!reHtml .Contains("注册网易免费邮箱"))
                {
                    status += "获取初始 失败";
                    return false;
                }
                string envalue = get_env(reHtml);

                url = "http://reg.email.163.com/unireg/call.do?cmd=register.formLog";
                postData = string.Format("opt=write_field&flow=main&field=name&result=done&uid={0}%40163.com&timecost={1}&level=info", user , new Random().Next(4000, 10000).ToString());
                items = new HttpItems()
                {
                    URL = url,
                    Cookie = Cookies,
                    Method = "post",
                    Postdata =postData ,
                    Referer = "http://reg.email.163.com/unireg/call.do?cmd=register.entrance&from=163navi%C2%AEPage=163",
                    // IsAjax = true,
                    ProxyIp = Proxy
                };
                hr = helper.GetHtml(items, ref Cookies);
                reHtml = hr.Html.Replace("\r\n", "").Replace("\t", "").Replace("\n", "");
                reHtml = reHtml.Trim();
                if (!reHtml.Contains("200"))
                {
                    status += "formlog验证,非200";
                    return false;
                }

                if (!CheckUserName(user))
                {
                    status = "检查用户名可注册性返回失败";
                    return false;
                }

                string sid = "";
                sid = GetStringMid(Cookies, "JSESSIONID=", ";");
                string sd = GetStringMid(Cookies, "ser_adapter=", ";");
                if (string.IsNullOrEmpty(sd))
                {
                    sd = Cookies.Substring(Cookies.IndexOf("ser_adapter=") + "ser_adapter=".Length);
                }
                //JSESSIONID=BAF169A63DC82B728981F6A35749F9A0;mailsync=06d9d949febba7cbad54129b7bc6c4671f685c44529e575c78fae60cb5cf36c103fc6b87d5685515a8dc42bce97830b5;ser_adapter=INTERNAL134
                //prepare
                cookieForPost = "";
                url = String.Format("https://ssl.mail.163.com/regall/unireg/prepare.jsp?sid={0}&sd={1}", sid, sd);
                items = new HttpItems()
                {
                    URL = url,
                    Cookie = cookieForPost,
                    ProxyIp = Proxy,
                    //KeepAlive = true,
                    CerPath = System.Environment.CurrentDirectory + @"\163reg.cer",
                    //ProtocolVersion = System.Net.HttpVersion.Version10
                    //IsAjax = true

                };
                //items.CerPath = System.Environment.CurrentDirectory + @"\163reg.cer";
                hr = helper.GetHtml(items, ref cookieForPost);
                GETVCODE:

                //获取验证码数据

                url = String.Format("http://reg.email.163.com/unireg/call.do?cmd=register.verifyCode&v=common/verifycode/vc_en&env={0}&t={1}", envalue, new XJHTTP().GetTimeByJs());
                items = new HttpItems()
                {
                    URL = url,
                    Cookie = Cookies,
                    ProxyIp = Proxy,
                    ResultType = ResultType.Byte
                };

                hr = helper.GetHtml(items,ref Cookies );
                //Cookies +=  HttpHelpers.GetSmallCookie(hr.Cookie);
                codebytes = hr.ResultByte;
                //获取验证码
                if (codebytes.Length < 100 || getImgCode == null || codebytes == null || string.IsNullOrEmpty(Vcode = getImgCode(codebytes)))
                {
                    string str = System.Text.Encoding.Default.GetString(codebytes);
                    str = GetStringMid(str, "msg\":\"", "\"");
                    status = "验证码识别有问题:" + str;
                    //status += hr.Html;
                    return false;
                }

                forlog(Cookies ,user ,pass );

                //JSESSIONID=BAF169A63DC82B728981F6A35749F9A0;mailsync=562d05ee8ccf61a2b72091d6f755dc026cce72127aef931f1a82e260197506399c1fe6c90e59d1dfa8dc42bce97830b5;ser_adapter=INTERNAL134

                //JSESSIONID=BAF169A63DC82B728981F6A35749F9A0;mailsync=562d05ee8ccf61a2b72091d6f755dc026cce72127aef931f1a82e260197506399c1fe6c90e59d1dfa8dc42bce97830b5;ser_adapter=INTERNAL134
                //Cookies +=  HttpHelpers.GetSmallCookie(hr.Cookie);
                //reHtml = hr.Html.Replace("\r\n", "").Replace("\t", "").Replace("\n", "");
               // Cookies =Cookies.Replace(";;",";");

                //正式提交注册数据
                url = String.Format("https://ssl.mail.163.com/regall/unireg/call.do;jsessionid={0}?cmd=register.start", sid);
                postData = String.Format(
                    "name={0}&flow=main&uid={1}%40163.com&password={2}&confirmPassword={3}&mobile=&vcode={4}&from=163navi%C2%AEPage%3D163"
                    , user, user, pass, pass, Vcode);
                items = new HttpItems()
                {
                    URL = url,
                    Cookie = cookieForPost,
                    ProxyIp = Proxy,
                    Method = "POST",
                    //PostDataType = CsharpHttpHelpers.Enum.PostDataType.String,
                    Postdata = postData,
                    //KeepAlive =true ,
                    Referer = "http://reg.email.163.com/unireg/call.do?cmd=register.entrance&from=163navi%C2%AEPage=163",
                    Allowautoredirect = false ,
                    //IsAjax =true ,
                    CerPath = System.Environment.CurrentDirectory + @"\163reg.cer",
                    //ProtocolVersion = System.Net.HttpVersion.Version10
                };
                hr = helper.GetHtml(items,ref cookieForPost);
               // Cookies +=  HttpHelpers.GetSmallCookie(hr.Cookie);
                reHtml = hr.Html.Replace("\r\n", "").Replace("\t", "").Replace("\n", "");
                reHtml = reHtml.Trim();

                ////Cookies = HttpHelpers.GetSmallCookie(Cookies );
                // url = string.Format("http://entry.mail.163.com/coremail/fcg/ntesdoor2");
                //items = new HttpItems()
                //{
                //    URL = url,
                //    Cookie = Cookies,
                //    ProxyIp = Proxy
                //};
                //hr = helper.GetHtml(items,ref Cookies);
                ////Cookies +=  HttpHelpers.GetSmallCookie(hr.Cookie);
                // reHtml = hr.Html.Replace("\r\n", "").Replace("\t", "").Replace("\n", "");
                ////reHtml = reHtml.Trim();
                //if (reHtml == "无法连接到远程服务器")
                //{
                //    status += "无法连接到远程服务器";
                //    return false;
                //}

                //{"code":401,"desc":"PARAMETER ERROR","msg":"VCODE_NOT_MATCH","result":863675}
                if (cookieForPost.Contains ("NTES_SESS") ||reHtml.Contains("注册成功") || reHtml.Contains("http://mail.163.com/dashi/activity/reg/ok.do?from=zimu"))
                {
                    File.AppendAllText(Environment.CurrentDirectory + @"\finishUsers.txt", string.Format("{0}----{1}\r\n", user, pass));
                    status += "注册成功\t";
                    Cookies = cookieForPost;
                    return true;
                    //MessageBox.Show("注册成功");
                }
                else
                {
                    yq.LogHelper.Debug("user :"******";pass:"******";msg" + reHtml);
                    string msg = GetStringMid(reHtml, "msg\":\"", "\"");
                    switch (string.IsNullOrEmpty(msg) ? reHtml : msg)
                    {
                        case "INVALID NAME":
                            status += "无效的用户名";
                            break;
                        case "NAME_EQUALS_PASSWORD":
                            status += "密码和用户名不能完全相同";
                            break;
                        case "NO_PASSWORD":
                            break;
                        case "NAME EQUALS PASSWORD":
                        case "PASSWORD TOO SIMPLE":
                            status += "密码过于简单,请尝试“字母+数字”的组合";
                            break;
                        case "NO_CONFIRMED_PASSWORD":
                        case "PASSWORD_NOT_MATCH":
                            break;
                        case "INVALID MOBILE":
                            status += "请填写有效的11位手机号码";
                            break;
                        case "BIND TOO MANY":
                            status += "该手机号码已绑定5个帐号,请编辑短信“JC”发送到 10690163331,取消手机和所有帐号的绑定关系";
                            break;
                        case "VCODE_NOT_MATCH":
                            goto GETVCODE;
                        default:
                            status += reHtml;
                            break;
                    }
                    return false;
                    //MessageBox.Show(reHtml);
                }
            }
            catch (Exception ex)
            {
            }
            /*
            this.handleMsg = function(U) {
            switch (U.msg) {
            case "INVALID NAME":
            d.showRemind("error", "name", "无效的用户名");
            j.name = false;
            break;
            case "ILLEGAL_UID":
            $("#nameIpt").blur();
            j.name = false;
            break;
            case "NAME_EQUALS_PASSWORD":
            d.showRemind("error", "mainPwd", "密码和用户名不能完全相同");
            j.pwd = false;
            break;
            case "NO_PASSWORD":
            $("#mainPwdIpt").blur();
            j.pwd = false;
            break;
            case "NAME EQUALS PASSWORD":
            case "PASSWORD TOO SIMPLE":
            d.showRemind("error", "mainPwd", "密码过于简单,请尝试“字母+数字”的组合");
            j.pwd = false;
            break;
            case "NO_CONFIRMED_PASSWORD":
            case "PASSWORD_NOT_MATCH":
            $("#mainCfwPwdIpt").blur();
            j.cfmPwd = false;
            break;
            case "INVALID MOBILE":
            d.showRemind("error", "mainMobile", "请填写有效的11位手机号码");
            j.mobile = false;
            break;
            case "BIND TOO MANY":
            d.showRemind("error", "mainMobile", "该手机号码已绑定5个帐号,请编辑短信“JC”发送到 10690163331,取消手机和所有帐号的绑定关系");
            j.mobile = false;
            break;
            case "VCODE_NOT_MATCH":
            d.showRemind("error", "vcode", "验证码不正确,请重新填写");
            if (U.result) {
                f.initEnv(U.result)
            }
            $("#vcodeImg").click();
            j.vcode = false;
            break;
            case "INVALID_SUSPEND":
            case "REGISTER_NOT_FOUND":
            $("#overdueTips").show();
            break;
            default:
            $("#overdueTips").show();
            break
            }
            */
            return false;
        }
Ejemplo n.º 25
0
        private void getUploadRs()
        {
            // Logscomsole(status);
            HttpHelpers helper_up = new HttpHelpers();
            HttpItems items_up = new HttpItems();
            HttpResults hr_up = new HttpResults();
            string url;
            string rehtml;

            url =string.Format ("http://download.csdn.net/my");
            items_up = new HttpItems() {
                URL = url,
                Container = cc
            };
            hr_up = helper_up.GetHtml(items_up);
            string DownHtml = hr_up.Html.Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace(" ", "");
            string result = Regex.Replace(DownHtml, @"<!--(.+?)-->", "");

            //获取下载资源数量
            Regex regDown = new Regex("上传资源:<spanclass=\"red\">(.+?)</span>");
            MatchCollection mcDown = regDown.Matches(result);
            double upCount = 0;
            if (mcDown.Count > 0)
            {
                upCount = Convert.ToDouble(mcDown[0].Groups[1].Value);
            }
            //Regex reg = new Regex("<dt><divclass=\"icon\"><imgsrc=\"(.+?)\"title=\"(.+?)\"></div><divclass=\"btns\"></div><h3><ahref=\"(.+?)\"(.*?)\">(.+?)</a><spanclass=\"points\">(.+?)</span></h3></dt>");
            Regex reg = new Regex("<dt><divclass=\"icon\"><imgsrc=\"(.+?)\"title=\"(.+?)\"></div><divclass=\"btns\">(<ahref=(.*?)删除</a>)?</div><h3><ahref=\"(.+?)\"(.*?)\">(.+?)</a><spanclass=\"points\">(.+?)</span></h3></dt>");
            MatchCollection mc = reg.Matches(result);
            if (mc.Count > 0)
            {
                foreach (Match item in mc)
                {
                    CsdnResouce cdsr = new CsdnResouce();
                    if (item.Groups.Count == 9)
                    {
                        cdsr.Url = item.Groups[5].Value;
                        cdsr.Name = item.Groups[7].Value;
                        cdsr.Point = item.Groups[8].Value;
                    }
                    else
                    {
                        cdsr.Url = item.Groups[3].Value;
                        cdsr.Name = item.Groups[5].Value;
                        cdsr.Point = item.Groups[6].Value;
                    }
                    //CsdnResouce cdsr = new CsdnResouce(tmp1[6], tmp1[4]);
                    cdsr.Tag = String.Format("http://download.csdn.net{0}", cdsr.Url);
                    uploadedRS.Add(cdsr );
                }
            }
            Logscomsole(new string[] { "获取上传资源", "结束", "共 " + upCount.ToString() + " 个资源", "", "" });
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 检查某用户名可否被注册
        /// </summary>
        /// <param name="username"></param>
        /// <returns></returns>
        private bool CheckUserName(string username)
        {
            try
            {
                string url = String.Format("http://reg.email.163.com/unireg/call.do?cmd=urs.checkName");
                string postdata = "name="+username ;
                items = new HttpItems()
                {
                    URL = url,
                    Cookie = Cookies,
                    Method = "post",
                    Postdata = postdata,
                    IsAjax = true

                };
                //items.Container = cc;
                // items.ProxyIp = proxy ;
                hr = helper.GetHtml(items,ref Cookies);
                //Cookies +=  HttpHelpers.GetSmallCookie(hr.Cookie);
                string reHtml = hr.Html.Replace("\r\n", "").Replace("\t", "").Replace("\n", "");
                reHtml = reHtml.Trim();
                //Cookiesss += hr.Cookie;
                if (reHtml.Contains("OK"))
                {
                    return true;
                }
            }
            catch (Exception ex)
            {
            }

            return false;
        }
Ejemplo n.º 27
0
        private string[] regForIn(string proxyip="")
        {
            Start:
            //string proxyip = "";
            int trytimes = 0;
            string[] status = { "操作", "成功/失败", "状态信息", "无验证码", "无附加信息" };
            status[0] = "注册帐号";
            status[1] = "开始";
            status[2] = "";
            status[3] = "";
            status[4] = "";
            Logscomsole(status);

            HttpItems items_reg = new HttpItems();
            HttpHelpers heler_reg = new HttpHelpers();
            HttpResults hr_reg = new HttpResults();

            CookieContainer cc_em = new CookieContainer();
            CookieContainer cc_reg = new CookieContainer();
            Regex regex = null;
            MatchCollection mc = null;

            byte[] regCodebytes = null;

            string email = "";
            string name = "";
            string regCode = "";

            //https://passport.csdn.net/ajax/verifyhandler.ashx//验证码
            hr_reg = heler_reg.GetHtml(new HttpItems()
            {
                URL = @"https://passport.csdn.net/ajax/verifyhandler.ashx",
                ResultType = ResultType.Byte,
                Container = cc_reg
            });

            regCodebytes = hr_reg.ResultByte;

            if (getRegVcode != null)
            {
                regCode = getRegVcode(regCodebytes);
            }
            if (regCode == "")
            {
                status[0] = "注册帐号";
                status[1] = "失败";
                status[2] = "识别验证码失败";
                status[3] = "重试申请";
                status[4] = "";
                Logscomsole(status);
                //reg();
                return regForIn();
            }
            //检查验证码
            //http://passport.csdn.net/account/register?action=validateCode&validateCode=
            items_reg = new HttpItems() {
                URL= "http://passport.csdn.net/account/register?action=validateCode&validateCode=" + regCode,
                Container =cc_reg
            };
            hr_reg = heler_reg.GetHtml(items_reg);
            if (hr_reg.Html.ToLower() != "true")
            {
                status[0] = "注册帐号";
                status[1] = "失败";
                status[2] = "识别验证码失败";
                status[3] = "重试申请";
                status[4] = "";
                Logscomsole(status);
                goto Start;
            }
            trytimes = 0;
            //检查名字
            //http://passport.csdn.net/account/register?action=validateUsername&username=
            //检查邮箱
            //http://passport.csdn.net/account/register?action=validateEmail&[email protected]
            //检查验证码
            //http://passport.csdn.net/account/register?action=validateCode&validateCode=
            //重发激活右键
            //http://passport.csdn.net/account/register?action=resendActiveEmail&username=
            GetMail:

            email = getRegEmail2(cc_em);
            //检查验证码
            //http://passport.csdn.net/account/register?action=validateCode&validateCode=

            hr_reg = heler_reg.GetHtml(new HttpItems() {
                URL = "http://passport.csdn.net/account/register?action=validateEmail&email=" + email,
                Container =cc_reg
            });
            if (hr_reg.Html.ToLower() != "true")
            {
                trytimes++;
                if (trytimes < 5)
                {
                    Logscomsole(new string[] { "注册帐号", "失败", "邮箱验证失败", hr_reg.Html, "" });
                    goto GetMail;
                }
                else
                {
                    Logscomsole(new string[] { "注册帐号","失败", "邮箱验证失败次数过多",hr_reg .Html ,"" });
                    return new string[] { };
                }
            }
            trytimes = 0;
            GetregName:
            name = GetName();
            //检查名字
            hr_reg = heler_reg.GetHtml(new HttpItems()
            {
                URL = "http://passport.csdn.net/account/register?action=validateUsername&username="******"true")
            {
                trytimes++;
                if (trytimes < 5)
                {
                    Logscomsole(new string[] { "注册帐号", "失败", "用户名验证失败", hr_reg.Html, "" });
                    goto GetregName;
                }
                else
                {
                    Logscomsole(new string[] { "注册帐号", "失败", "用户名验证失败次数过多", hr_reg.Html, "" });
                    return new string[] { };
                }
            }
            //string email = string.Format("{0}@qq.com", name);
            string pwd = string.IsNullOrEmpty(mima) ? "aa13655312932bb" : mima;
            Logscomsole(new string[] { "注册帐号", "进行中", "验证成功", "用户名:" + name, "邮箱:" + email });
            PostRequest:

            #region 提交注册请求

            hr_reg = heler_reg.GetHtml(new HttpItems()
            {
                Container = cc_reg,
                URL = "http://passport.csdn.net/account/register?action=saveUser&isFrom=False",
                Postdata = string.Format("fromUrl={0}&userName={1}&email={2}&password={3}&confirmpassword={4}&validateCode={5}&agree=on",
                string.Empty, name, email, pwd, pwd, regCode),
                Method = "POST",

                ProxyIp = proxyip,
            });
            int trycount = 0;
              WaitForEmail:
            trycount++;
            string html = hr_reg.Html.Replace("\r\n", "").Replace("\t", "").Replace("\n", "");

            if (html.Contains("邮件已发送到邮箱")||html .Contains ("不允许在一分钟内重复发送激活邮件,请稍后"))
            {
                Logscomsole(new string[] {"注册帐号","进行中","激活邮件已发送", "等待邮件到达","" });
                string str = "";
                if (!(str = activeRegEmai2(email, cc_em)).Contains("失败"))
                {
                    str = "http" + str.Substring(5);
                    hr_reg = new HttpHelpers().GetHtml(new HttpItems() {
                        URL =str.Replace ("https","http") ,
                        ProxyIp =proxyip ,
                        //Allowautoredirect =true
                    });

                    hr_reg = new HttpHelpers().GetHtml(new HttpItems()
                    {
                        URL = str.Replace("https", "http"),
                        ProxyIp = proxyip,
                        //Allowautoredirect =true
                    });
                    string htmlss = hr_reg.Html;
                    if (htmlss.Contains("注册成功")||htmlss .Contains ("账户已经激活"))
                    {
                        status[0] = "注册帐号";
                        status[1] = "成功";
                        status[2] = "帐号:" + name;
                        status[3] = "密码:" + pwd;
                        status[4] = "";
                        Logscomsole(status);
                        return new string[] { name, pwd };
                    }
                    else
                    {
                        status[0] = "注册帐号";
                        status[1] = "失败";
                        status[2] = htmlss;
                        status[3] = "";
                        status[4] = "";
                        Logscomsole(status);
                        return new string[] { };
                    }
                }
                else
                {

                     if(trycount <7)
                    {

                        if (trycount % 5 == 0)
                        {
                            status[0] = "注册帐号";
                            status[1] = "进行中";
                            status[2] = "重发邮件" + name;
                            status[3] = "15秒后重新检测";
                            status[4] = "";
                            Logscomsole(status);
                            hr_reg = new HttpHelpers().GetHtml(new HttpItems()
                            {
                                URL = string.Format("http://passport.csdn.net/account/register?action=resendActiveEmail&username={0}", name),
                                ProxyIp =proxyip
                            });
                        }
                        else
                        {
                            status[0] = "注册帐号";
                            status[1] = "进行中";
                            status[2] = "等待激活邮件" + name;
                            status[3] = "15秒后重新检测";
                            status[4] = "";
                            Logscomsole(status);
                        }
                        goto WaitForEmail;
                    }

                    status[0] = "注册帐号";
                    status[1] = "失败";
                    status[2] = "激活邮箱问题";
                    status[3] = str;
                    status[4] = "";
                    Logscomsole(status);
                    if (str.Contains("errorerror"))
                    {
                        return regForIn();
                    }
                    return new string[] { str };
                }
            }
            else
            {
                status[0] = "注册帐号";
                status[1] = "失败";

                if (html.Contains("此ip单位时间内注册个数已超过限定值"))
                {
                    //if (regeristResult != null)
                    //{
                    //    regeristResult();
                    //}
                    status[2] = "此ip单位时间内注册个数已超过限定值";
                    status[3] = "";
                    status[4] = "";
                    Logscomsole(status);
                    return new string[] { "单位时间内注册个数已超过限定值" };
                }
                else
                {
                    status[2] = "验证码错误";
                    status[3] = "重试申请";
                    status[4] = html;
                    Logscomsole(status);
                    goto Start;
                    // return;
                }
            }
            #endregion

            status[0] = "注册帐号";
            status[1] = "失败";
            status[2] = "未知原因";
            status[3] = "";
            status[4] = "";
            Logscomsole(status);

            return new string[] { };
        }
Ejemplo n.º 28
0
        /// <summary>
        /// 根据相传入的数据,得到相应页面数据
        /// </summary>
        /// <param name="strPostdata">传入的数据Post方式,get方式传NUll或者空字符串都可以</param>
        /// <returns>string类型的响应数据</returns>
        private HttpResults GetHttpRequestData(HttpItems objHttpItems)
        {
            //返回参数
            HttpResults result = new HttpResults();
            try
            {
                #region 得到请求的response

                result.CookieCollection = new CookieCollection();
                response = (HttpWebResponse)request.GetResponse();

                result.Header = response.Headers;
                if (response.Cookies != null)
                {
                    result.CookieCollection = response.Cookies;
                }
                if (response.Headers["set-cookie"] != null)
                {
                    result.Cookie = response.Headers["set-cookie"];
                }
                //处理返回值Container
                result.Container = objHttpItems.Container;
                MemoryStream _stream = new MemoryStream();
                //GZIIP处理
                if (response.ContentEncoding != null && response.ContentEncoding.Equals("gzip", StringComparison.InvariantCultureIgnoreCase))
                {
                    _stream = GetMemoryStream(new GZipStream(response.GetResponseStream(), CompressionMode.Decompress));
                }
                else
                {
                    _stream = GetMemoryStream(response.GetResponseStream());
                }
                //获取Byte
                byte[] RawResponse = _stream.ToArray();
                //是否返回Byte类型数据
                if (objHttpItems.ResultType == ResultType.Byte)
                {
                    result.ResultByte = RawResponse;
                    return result;
                }
                //无视编码
                if (encoding == null)
                {
                    string temp = Encoding.Default.GetString(RawResponse, 0, RawResponse.Length);
                    //<meta(.*?)charset([\s]?)=[^>](.*?)>
                    Match meta = Regex.Match(temp, "<meta([^<]*)charset=([^<]*)[\"']", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                    string charter = (meta.Groups.Count > 2) ? meta.Groups[2].Value : string.Empty;
                    charter = charter.Replace("\"", string.Empty).Replace("'", string.Empty).Replace(";", string.Empty);
                    if (charter.Length > 0)
                    {
                        charter = charter.ToLower().Replace("iso-8859-1", "gbk");
                        encoding = Encoding.GetEncoding(charter);
                    }
                    else
                    {
                        if (response.CharacterSet != null)
                        {
                            if (response.CharacterSet.ToLower().Trim() == "iso-8859-1")
                            {
                                encoding = Encoding.GetEncoding("gbk");
                            }
                            else
                            {
                                if (string.IsNullOrEmpty(response.CharacterSet.Trim()))
                                {
                                    encoding = Encoding.UTF8;
                                }
                                else
                                {
                                    encoding = Encoding.GetEncoding(response.CharacterSet);
                                }
                            }
                        }
                    }
                }
                //得到返回的HTML
                try
                {
                    if (RawResponse.Length > 0)
                    {
                        result.Html = encoding.GetString(RawResponse);
                    }
                    else
                    {
                        result.Html = "";
                    }
                    _stream.Close();
                    response.Close();
                }
                catch
                {
                    return null;
                }
                //最后释放流

                #endregion 得到请求的response
            }
            catch (WebException ex)
            {
                //这里是在发生异常时返回的错误信息
                result.Html = "String Error";
                response = (HttpWebResponse)ex.Response;
                return result;
            }
            if (objHttpItems.IsToLower)
            {
                result.Html = result.Html.ToLower();
            }
            return result;
        }
Ejemplo n.º 29
0
 /// <summary>
 /// 获取通知
 /// </summary>
 public void GetMsg()
 {
     hr_down = new HttpHelpers().GetHtml(new HttpItems() {
         URL = "http://msg.csdn.net/",
         Container =cc
     });
     string rehtml = hr_down.Html.Replace("\r", "").Replace("\n", "").Replace("\t", "").Replace(" ", "");
     if (rehtml != "")
     {
         //很遗憾,您上传的资源hosts修改工具因资源违规没有通过审核
         string restr = "很遗憾,您上传的资源(.*?)没有通过审核";
         Regex reg = new Regex(restr );
         MatchCollection mct = reg.Matches(rehtml);
         if (mct.Count > 0)
         {
             Logscomsole(new string[] { "检查通知", "失败,有错喽", mct.Count.ToString(), mct[0].Groups[1].Value.ToString(), "" });
         }
     }
 }
Ejemplo n.º 30
0
 /// <summary>
 /// 读取返回对象中数据,并返回Image格式图片
 /// </summary>
 /// <param name="hr">GetHtml后的请求结果</param>
 /// <returns></returns>
 public Image GetImg(HttpResults hr)
 {
     return(byteArrayToImage(hr.ResultByte));
 }
Ejemplo n.º 31
0
        private void btnPost_Click(object sender, EventArgs e)
        {
            //post 数据
            string PostD = string.Format("{0}", txtVcode.Text);
            item.URL = PostUrl;
            item.Referer = BaseUrl;
            item.Method = "Post";
            item.IsAjax = true;
            item.ResultType = ResultType.String;
            item.Postdata = PostD;
            item.Container = cc;
            hr = http.GetHtml(item);
            if (!string.IsNullOrEmpty(hr.Html))
            {

            }
        }