日期:2014-05-17 浏览次数:20938 次
public string login()
{
string m_Name = "";//用户名
string m_Password = "";//密码
string url = "http://login.taobao.com/member/login.jhtml";
string indata = "action=Authenticator&CtrlVersion=1,0,0,7&event_submit_do_login=anything&fc=2&from=tb&gvfdcname=10&gvfdcre=687474703A2F2F7777772E74616F62616F2E636F6D2F&loginType=3&longLogin=-1&pstrong=2&style=default&support=000001&tid=XOR_1_000000000000000000000000000000_675843554D0B09747B737579&TPL_username="+m_Name+"&TPL_password="+m_Password+"&TPL_redirect_url=";
return HttpRequestPost(url, indata);
}
public CookieContainer mycookie=new CookieContainer();
string str = "";
public string HttpRequestPost(string url, string indata)
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = indata.Length;
request.Method = "POST";
request.Timeout = 3 * 60000;
request.CookieContainer = mycookie;
request.AllowAutoRedirect = true;
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)";
request.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/msword, */*";
Stream requestStream = null;
StreamWriter writer = null;
requestStream = request.GetRequestStream();//获取请求数据流句柄
writer = new StreamWriter(requestStream, Encoding.GetEncoding("gbk"));