|
namespace 窗口程序
{
class datum
{
public string User { get; set; }
public string Pass { get; set; }
public string Verify { get; set; }
public string Cookie { get; set; }
public string Logo()
{
HttpHelper Http = new HttpHelper();
HttpItem item = new HttpItem()
{
URL = "https://sso.letv.com/user/loginsubmit",
Method = "post",
Postdata = string.Format(@"loginname={0}&account={1}&password={2}&autologin=true&memberme=true&referrer=http%3A%2F%2Fshop.letv.com%2F&verify={3}&encoder=&newLogin=&callback=iframeSubmit_139788743214515119", User,User,Pass ,Verify ),
ContentType = "application/x-www-form-urlencoded",//返回类型 可选项有默认值
//Allowautoredirect = true,//自动跳转
//AutoRedirectCookie=true,//是否自动处理Cookie
ResultCookieType = ResultCookieType.CookieCollection
};
HttpResult result = Http.GetHtml(item);
string html = result.Html;
string flag;
string username;
flag = Between(html, "flag" + "\":\"", "\"");
username = Between(html, "username" + "\":\"", "\"");
if (flag == "200")
{
Cookie = result.Cookie;
return "登录成功:" + username;
}
else if (flag == "401")
{
return "密码错误";
}
else if (flag == "405" || flag == "406")
{
return "请输入验证码";
}
else if (flag == "403")
{
return "邮箱未激活";
}
else
{
return "未知错误!";
}
}
public static string Between(string str, string leftstr, string rightstr) //取中间文本
{
int i = str.IndexOf(leftstr) + leftstr.Length;
string temp = str.Substring(i, str.IndexOf(rightstr, i) - i);
return temp;
}
}
}
Cookie为什么会返回空?在商城看到乐视登录例子的Cookie不是空的,我弄成多线程为啥是空?
|
|