Exemplo n.º 1
0
        private static void GetToken(WebSiteModel model)
        {
            var result = http.GetHtml(new HttpItem()
            {
                URL = model.SiteDomin
            });

            model.Result = result;
            model.Token  = RegexHelper.GeMidStringValue(result.Html, "var token = '", "';");
            model.Cookie = result.Cookie;
        }
Exemplo n.º 2
0
        private void PostSign(WebSiteModel model)
        {
            var result = http.GetHtml(new HttpItem()
            {
                URL              = model.SignRequestUrl,
                Cookie           = model.Result.Cookie,
                Referer          = model.SiteDomin,
                Method           = "Get",
                Timeout          = 100000,                              //连接超时时间     可选项默认为100000
                ReadWriteTimeout = 30000,                               //写入Post数据超时时间     可选项默认为30000
                //UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36",//用户的浏览器类型,版本,操作系统     可选项有默认值
                Accept      = "application/json, text/javascript, */*", //    可选项有默认值
                ContentType = "application/x-www-form-urlencoded",      //返回类型    可选项有默认值
            });

            model.Result = result;
        }
Exemplo n.º 3
0
        public void TestMethod1()
        {
            WebSiteModel model = new WebSiteModel()
            {
                SiteDomin      = "http://www.17sucai.com/",
                SiteName       = "17素材网",
                LoginUrl       = "http://www.17sucai.com/auth",
                LoginName      = "*****@*****.**",
                LoginPwd       = "*************",
                SignRequestUrl = "http://www.17sucai.com/member/signin",
            };

            model.LoginPwd = Encrypt.SHA1Encrypt(model.LoginPwd).ToLower();
            GetToken(model);
            //登陆
            PostLogin(model);
            if (model.Result.Html.Contains("ret\":1"))//登陆成功
            {
                PostSign(model);
            }
        }
Exemplo n.º 4
0
        private void PostLogin(WebSiteModel model)
        {
            model.Token     = System.Web.HttpUtility.UrlEncode(model.Token);
            model.LoginName = System.Web.HttpUtility.UrlEncode(model.LoginName);
            string   postData = string.Format("email={0}&password={1}&token={2}", model.LoginName, model.LoginPwd, model.Token);
            HttpItem item     = new HttpItem()
            {
                URL              = model.LoginUrl,
                Postdata         = postData,
                Cookie           = model.Cookie,
                Referer          = model.SiteDomin,
                Method           = "POST",
                Timeout          = 100000,                              //连接超时时间     可选项默认为100000
                ReadWriteTimeout = 30000,                               //写入Post数据超时时间     可选项默认为30000
                //UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36",//用户的浏览器类型,版本,操作系统     可选项有默认值
                Accept      = "application/json, text/javascript, */*", //    可选项有默认值
                ContentType = "application/x-www-form-urlencoded",      //返回类型    可选项有默认值
            };
            var result = http.GetHtml(item);

            model.Result = result;
        }