模拟登录阿里联盟,为什么一直提示过期的页面?请大侠帮忙看看!!!!
模拟登录阿里联盟,为什么一直提示过期的页面?请大侠帮忙看看!!!!
附我写的代码:
http://download.csdn.net/detail/webajax/6570669
using System;
using System.Windows.Forms;
using DotNet.Utilities;
using System.Security.Cryptography;
using System.Text;
namespace LoginDemo
{
public partial class Form1 : Form
{
HttpHelper request = new HttpHelper();
public Form1()
{
InitializeComponent();
}
private void btn_login_Click(object sender, EventArgs e)
{
string tbtoken = string.Empty;
HttpItem item = new HttpItem();
item.URL = "http://www.alimama.com/member/minilogin.htm";
HttpResult html = request.GetHtml(item);
tbtoken = GetCookieValue(html.Cookie, "HttpOnly,_tb_token_");
if (string.IsNullOrEmpty(tbtoken))
{
MessageBox.Show("未获取_tb_token的值");
return;
}
string username = txt_user.Text.Trim();
string pwd = txt_pwd.Text.Trim();
string md5pwd = CalculateMD5Hash(pwd).ToLower();
item = new HttpItem();
item.URL = "https://www.alimama.com/member/minilogin_act.htm";
item.Referer = "http://www.alimama.com/member/minilogin.htm";
item.Method = "POST";
item.UserAgent = "User-Agent':'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.36";
item.Header.Add("DNT", "1");
item.Cookie = GetLoginCookie(html);
RequestData data = new RequestData();
data.AddField("_tb_token_", tbtoken);
data.AddField("logname", username);
data.AddField("logpasswd", md5pwd);
data.AddField("originalLogpasswd", pwd);
data.AddField("proxy", "");
data.AddField("redirect", "");
data.AddField("style", "");
item.PostDataType = PostDataType.String;
item.Postdata = data.GetData("UTF-8");
item.Allowautoredirect = false;
html = request.GetHtml(item);
rtb_value.Text = html.Html;
}
public string GetLoginCookie(HttpResult html)
{
string s = "";
s = "_tb_token_=" + GetCookieValue(html.Cookie,"HttpOnly,_tb_token_");
s += "; cookie2=" + GetCookieValue(html.Cookie, "cookie2");
s += "; rurl=";
s += "; t=" + GetCookieValue(html.Cookie, "HttpOnly,t");
s += "; v=0";
return s;
}
public string CalculateMD5Hash(string input)
{
// step 1, calculate MD5 hash from input
MD5 md5 = System.Security.Cryptography.MD5.Create();
byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);
byte[] hash = md5.ComputeHash(inputBytes);
// step 2, convert byte array to hex string
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hash.Length; i++)
{
sb.Append(hash[i].ToString("X2"));
}
return sb.ToString();
}
public string GetCookieValue(string cookie, string key)
{
if (string.IsNullOrEmpty(cookie)) return "";
string[] list = cookie.Split(';');
foreach (string s in list)
{
string[] t = s.Split('=');
if (t.Length == 2 && t[0].Equals(key, StringComparison.CurrentCultureIgnoreCase))
{
return t[1];
}
}
return "";
}
}
}
附我写的代码:
http://download.csdn.net/detail/webajax/6570669
...全文
相关推荐
阿里联盟模拟登录
使用C#进行代码模拟登录阿里联盟网,目前登录还存在小问题。仅供参考
C#模拟登录淘宝联盟并下载淘宝客订单xls
用C#实现模拟登录淘宝联盟非WebBrowser方式实现,请参考教程http://blog.csdn.net/hdlovefork/article/details/9823113
C#模拟登录淘宝联盟下载淘宝客订单xls
本程序用C#实现模拟登录淘宝联盟并且下载淘宝客订单xls,提供源码和教程文章http://blog.csdn.net/hdlovefork/article/details/9823113
基于Java语言开发的模拟WebQQ登录协议实现英雄联盟官网自动化登录工具_模拟WebQQ登录协议实现英雄联盟官网自动化登录工具_模拟WebQQ登录协议实现英雄联盟官网自动化登录工.zip
基于Java语言开发的模拟WebQQ登录协议实现英雄联盟官网自动化登录工具_模拟WebQQ登录协议实现英雄联盟官网自动化登录工具_模拟WebQQ登录协议实现英雄联盟官网自动化登录工.zip
HttpHelper类登录淘宝联盟并下载淘宝客订单xls
本文使用HttpHelper 1.3版本(因为我用VS2005开发,1.3报错少)实现模拟登录淘宝联盟并且下载淘宝客订单xls文件。现提供源码下载,有不明白的可以问我,同时如果您有好的修改建议请回复。我是第一次开发Http程序,请多包涵。



