示例#1
0
        /// <summary>
        /// 登录DZ
        /// </summary>
        /// <param name="Url">logging.php地址.请附带?action=login添加</param>
        /// <param name="LoginName">登录名(用户名、邮箱或者uid)</param>
        /// <param name="LoginNameType">登录名类型(用户名、邮箱或者uid)</param>
        /// <param name="Password">密码</param>
        /// <param name="VCode">验证码(暂时未支持)</param>
        /// <param name="Questionid">登录提示问题id</param>
        /// <param name="Answer">答案</param>
        /// <param name="Charset">网页编码</param>
        /// <param name="Proxy">代理(不使用请传入null)</param>
        /// <returns></returns>
        public static CookieContainer Login(string Url, string LoginName, LoginNameType LoginType, string Password, string VCode, string Questionid, string Answer, string Charset, WebProxy Proxy)
        {
            string          returnData    = "";
            string          formhash      = "";
            CookieContainer objCookie     = new CookieContainer();
            Httper          objPostHttper = new Httper();

            objPostHttper.Url     = Url;
            objPostHttper.Charset = Charset;
            objPostHttper.Cookie  = objCookie;
            if (Proxy != null)
            {
                objPostHttper.Proxy = Proxy;
            }

            try
            {
                formhash = RegexUtility.GetMatch(objPostHttper.HttpGet(), "formhash=(.*)\"");

                objPostHttper.PostData = string.Format("&formhash={0}&referer=index.php&loginfield={5}&username={1}&password={2}&questionid={3}&answer={4}&cookietime=2592000&loginsubmit=%CC%E1%BD%BB"
                                                       , formhash, LoginName, Password, Questionid, Answer, LoginType.ToString().ToLower());
                returnData = objPostHttper.HttpPost();
                if (returnData.IndexOf("欢迎您回来") > 0)
                {
                    //登录成功,返回cookie
                    return(objCookie);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(null);
        }
示例#2
0
        /// <summary>
        /// ��¼DZ
        /// </summary>
        /// <param name="Url">logging.php��ַ.�븽��?action=login���</param>
        /// <param name="LoginName">��¼�����û������������uid��</param>
        /// <param name="LoginNameType">��¼�����ͣ��û������������uid��</param>
        /// <param name="Password">����</param>
        /// <param name="VCode">��֤��(��ʱδ֧��)</param>
        /// <param name="Questionid">��¼��ʾ����id</param>
        /// <param name="Answer">��</param>
        /// <param name="Charset">��ҳ����</param>
        /// <param name="Proxy">����(��ʹ���봫��null)</param>
        /// <returns></returns>
        public static CookieContainer Login(string Url, string LoginName, LoginNameType LoginType, string Password, string VCode, string Questionid, string Answer, string Charset, WebProxy Proxy)
        {
            string returnData = "";
            string formhash = "";
            CookieContainer objCookie = new CookieContainer();
            Httper objPostHttper = new Httper();
            objPostHttper.Url = Url;
            objPostHttper.Charset = Charset;
            objPostHttper.Cookie = objCookie;
            if (Proxy != null)
            {
                objPostHttper.Proxy = Proxy;
            }

            try
            {
                formhash = RegexUtility.GetMatch(objPostHttper.HttpGet(), "formhash=(.*)\"");

                objPostHttper.PostData = string.Format("&formhash={0}&referer=index.php&loginfield={5}&username={1}&password={2}&questionid={3}&answer={4}&cookietime=2592000&loginsubmit=%CC%E1%BD%BB"
                    , formhash, LoginName, Password, Questionid, Answer, LoginType.ToString().ToLower());
                returnData = objPostHttper.HttpPost();
                if (returnData.IndexOf("��ӭ������") > 0)
                {
                    //��¼�ɹ�,����cookie
                    return objCookie;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return null;
        }
示例#3
0
        private string ConnectValidatePage(AsyncOperation asyncOp, ProxyInfo info)
        {
            Natsuhime.Events.MessageEventArgs e = null;
            if (info != null)
            {
                try
                {
                    httper.Proxy = new System.Net.WebProxy(info.Address, info.Port);
                    System.Diagnostics.Debug.WriteLine(string.Format("{0}:{1}", info.Address, info.Port));
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.Write("error uri" + info.Address + "-" + info.Port);
                    e = new Natsuhime.Events.MessageEventArgs("", string.Format("[代理错误:{2}]{0}:{1}", info.Address, info.Port, ex.Message), "", asyncOp.UserSuppliedState);
                    asyncOp.Post(this.onStatusChangeDelegate, e);
                }
            }

            httper.Url     = _ProxyValidateUrlInfo.Url;
            httper.Charset = _ProxyValidateUrlInfo.Charset;
            return(httper.HttpGet());
        }