c# 登录淘宝 httpwebrequest
c# 登录淘宝 httpwebrequest
最近在写个淘宝相关的程序,一向很熟悉httpWebRequest的,却在程序中浪费了很多时间,呵呵,还是不够细心啊。虽然TopApi很好很方便,但是对于非商城类用户,想接入并投入使用真不容易,所以这里给个登淘宝的关键代码,希望能帮到您。。。。
public static string getSaleInfo(string User, string psw, string VCode, int myIndex)
{
string tmpUser = myEncoding(User, 1); string tmpPsw = psw; string tmpVCode = VCode;
if (tmpToken == "") return "初始化登录失败";
string strData = string.Format("TPL_username={0}&TPL_password={1}"+
"&action=Authenticator&event_submit_do_login=anything&TPL_redirect_url=http%3A%2F%2Fwww.taobao.com&from=tb&fc=2&style=" +
"default&css_style=&tid=XOR_1_000000000000000000000000000000_6358305443087C737B03067F" +
"&support=000001&CtrlVersion=1%2C0%2C0%2C7&loginType=3&minititle=&minipara=&pstrong=1&longLogin=-1&llnick=" +
"&sign=&need_sign=&isIgnore=&popid=&callback=&guf=¬_duplite_str=&need_user_id=&poy=&gvfdcname=10&" +
"from_encoding=TPL_username={0}&TPL_password={1}&_tb_token_={2}&action=Authenticator&" +
"event_submit_do_login=anything&TPL_redirect_url=http%3A%2F%2Fwww.taobao.com%2F&from=tb&fc=2&style=default&css_style=&tid=XOR_1_000000000000000000000000000000_6358305443087C737B03067F" +
"&support=000001&CtrlVersion=1%2C0%2C0%2C7&loginType=3&minititle=&minipara=&pstrong=1&longLogin=-1&llnick=&sign=&need_sign=&isIgnore=&popid=&callback=&guf=" +
"¬_duplite_str=&need_user_id=&poy=&gvfdcname=10&from_encoding=", tmpUser, tmpPsw, tmpToken);
//string strData = string.Format("TPL_username={0}&TPL_password={1}&_tb_token_={2}&action=Authenticator&event_submit_do_login=anything&TPL_redirect_url=http%3A%2F%2Fwww.taobao.com%2F&from=tb&fc=2&style=default&css_style=&tid=XOR_1_000000000000000000000000000000_6358305443087C737B03067F&support=000001&CtrlVersion=1%2C0%2C0%2C7&loginType=3&minititle=&minipara=&pstrong=2&longLogin=-1&llnick=&sign=&need_sign=&isIgnore=&popid=&callback=&guf=¬_duplite_str=&need_user_id=&poy=&gvfdcname=10&from_encoding="
// ,tmpUser,tmpPsw,tmpToken);
string strUrl1 = "https://login.taobao.com/member/login.jhtml";//?redirect_url=http%3A%2F%2Fwww.taobao.com%2F";//此处链接换了就not Ok了.
string tmpStr = Execute(strUrl1, "post", strData, "gb2312");
//getComplain 注意与其它url的顺序
tmpStr = Execute(strUrl, "get", "", "gb2312");
int iComplain = 0;
string tmpComplain = myMatch(tmpStr, "(?<=收到投诉\\(<em>).*(?=</em>\\))", 0);
try
{
iComplain = int.Parse(tmpComplain);
}
catch
{
}
//strUrl = "http://jianghu.taobao.com/admin/home.htm";
//tmpStr = Execute(strUrl, "get", "", "gb2312");
//I'm seller
strUrl = "http://i.taobao.com/my_taobao.htm?seller=true";
tmpStr = Execute(strUrl, "get", "", "gb2312");
string tmpWaitSend = myMatch(tmpStr, "(?<=>待发货订单\\(<em>).*(?=</em>\\))", 0);
string tmpRefunding = myMatch(tmpStr, "(?<=>退款中订单\\(<em>).*(?=</em>\\))", 0);
int iRefunding = 0;
int iWaitSend = 0;
try
{
iWaitSend = int.Parse(tmpWaitSend);
}
catch
{
}
try
{
iRefunding = int.Parse(tmpRefunding);
}
catch
{
}
return "getOK"; } Powered By Error Q:302777528
app.myReport[myIndex].User = User;
app.myReport[myIndex].iWaitSend = iWaitSend;
app.myReport[myIndex].iExitFund = iRefunding;
app.myReport[myIndex].iCompain = iComplain;
//nekot=g%2C27nmtugg5s62fnpk1297864546431
// System.Diagnostics.Debug.Print(tmpStr);
评论已关闭