网站首页> 日志> 淘宝模拟登录_阿里妈妈后台
淘宝模拟登录_阿里妈妈后台
编辑时间:2017-03-24 23:58:36 作者:李大宝 浏览量:2834

淘宝模拟登录(C#编写)

1.一种直接使用程序以请求的方式登录,如果有图片验证码(可以利用打码平台来解决),但是淘宝是用的滑动验证,只能通过第二种方法来解决,请求方式的部分代码如下:

        /// <summary>
        /// 判断是否需要验证码
        /// </summary>
        /// <returns></returns>
        public string IsNeedCode()
        {
            TempCookie = "";
            string codePath = "";
            item = new HttpItem()
            {
                URL = "https://login.taobao.com/member/login.jhtml?style=mini&css_style=alimama&from=alimama&redirectURL=http%3A%2F%2Fwww.alimama.com&full_redirect=true",
                Method = "GET",
                Accept = "application/json, text/javascript, */*; q=0.01"
            };
            result = http.GetHtml(item);
            TempCookie = result.Cookie;
            retCode = result.Html;
            item = new HttpItem()
            {
                URL = "https://login.taobao.com/member/request_nick_check.do?_input_charset=utf-8",
                Method = "POST",
                Accept = "application/json, text/javascript, */*",
                Referer = "https://login.taobao.com/member/login.jhtml?style=mini&css_style=alimama&from=alimama&redirectURL=http%3A%2F%2Fwww.alimama.com&full_redirect=true",
                Postdata = "username=" + Account + "&ua=",
                Cookie = TempCookie
            };
            item.Header.Add("X-Requested-With", "XMLHttpRequest");
            result = http.GetHtml(item);
            TempCookie += result.Cookie;
            retCode = result.Html;
            if (retCode.Contains("needcode\":true"))
            {
                codePath = Utils.GetMidStr(retCode, "url\":\"", "\"") + "&_r_=" + Utils.GetTime();
            }
            return codePath;
        }


        /// <summary>
        /// 提交验证码,并登录
        /// </summary>
        /// <param name="code">验证码</param>
        /// <returns>如果验证码错误,再次返回验证码路径</returns>
        public string SubmitCode(string code)
        {
            item = new HttpItem()
            {
                URL = "https://login.taobao.com/member/login.jhtml",
                Method = "POST",
                Accept = "application/json, text/javascript, */*; q=0.01",
                Referer = "https://login.taobao.com/member/login.jhtml?style=minisimple&from=alimama&redirectURL=http%3A%2F%2Flogin.taobao.com%2Fmember%2Ftaobaoke%2Flogin.htm%3Fis_login%3d1&full_redirect=true&disableQuickLogin=true",
                Postdata = "ua=&TPL_username=" + Account + "&TPL_password=" + Pwd + "&TPL_checkcode=" + code +
"&loginsite=0&newlogin=1&TPL_redirect_url=&from=alimama&fc=default&style=minisimple&css_style=&tid=&support=000001&CtrlVersion=1%2C0%2C0%2C7&loginType=3&minititle=&minipara=&umto=NaN&pstrong=3&llnick=&sign=&need_sign=&isIgnore=&full_redirect=&popid=&callback=1&guf=&not_duplite_str=&need_user_id=&poy=&gvfdcname=&gvfdcre=&from_encoding=&sub=&allp=&oslanguage=zh-cn&sr=1440*900&osVer=windows%7C5.1&naviVer	=ie|8",
                Cookie = TempCookie
            };
            item.Header.Add("X-Requested-With", "XMLHttpRequest");
            result = http.GetHtml(item);
            TempCookie += result.Cookie;
            retCode = result.Html;
            //判断验证码是否输入正确
            if (retCode.Contains("验证码错误,请重新输入"))
            {
                return Utils.GetMidStr(retCode, "ccurl\":\"", "\"");
            }
            else
            {
                return "";
            }
        }



2.利用webBrowser控件加载淘宝登陆网页,进行模拟输入,模拟点击,模拟滑动。完全自动化,服务器托管。效果如下:


0


上面动图,完全是由程序控制,具体思路

1.webBrowser载入淘宝登陆网页

2.自动填入账号和密码

3.模拟滑动,首先把定位到滑动按钮上面,然后模拟鼠标按下,模拟鼠标移动,最终模拟鼠标放开。

        //鼠标移动
        //dX和dy保留移动的信息。给出的信息是绝对或相对整数值。
        public static readonly int MOUSEEVENTF_MOVE = 0x0001;
        //绝对位置
        //则dX和dy含有标准化的绝对坐标,其值在0到65535之间。
        //事件程序将此坐标映射到显示表面。
        //坐标(0,0)映射到显示表面的左上角,(65535,65535)映射到右下角
        //如果没指定MOUSEEVENTF_ABSOLUTE,dX和dy表示相对于上次鼠标事件产生的位置(即上次报告的位置)的移动。
        //正值表示鼠标向右(或下)移动;负值表示鼠标向左(或上)移动。
        public static readonly int MOUSEEVENTF_ABSOLUTE = 0x8000;
        public static readonly int MOUSEEVENTF_LEFTDOWN = 0x0002;//左键按下
        public static readonly int MOUSEEVENTF_LEFTUP = 0x0004;//左键抬起
        public static readonly int MOUSEEVENTF_RIGHTDOWN = 0x0008; //右键按下 
        public static readonly int MOUSEEVENTF_RIGHTUP = 0x0010; //右键抬起 
        public static readonly int MOUSEEVENTF_MIDDLEDOWN = 0x0020; //中键按下 
        public static readonly int MOUSEEVENTF_MIDDLEUP = 0x0040;// 中键抬起 

        [DllImport("User32.dll")]
        public static extern bool GetCursorPos(out Point pt);

        [DllImport("User32.dll", EntryPoint = "SetCursorPos")]
        public static extern void SetCursorPos(int x, int y);

        [DllImport("user32", EntryPoint = "mouse_event")]
        public static extern int mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);


4.获取到登录的cookie,就可以做你想做的任何事情了,比如淘宝刷单,淘宝客申佣,淘宝客定向计划自动申请等等


发表评论,请先 登录

袭人 

2018-08-16
00000000000000000