Пример #1
0
        public void Remove(ref HttpRequest request)
        {
            string htmlPageCart = request.Get("https://cart.lazada.vn/cart").ToString();

            HTML = htmlPageCart;
            HTML = Regex.Unescape(HTML);
            string stringJson = Regex.Match(HTML, "window.__initData__ = [^;]+").Value.Replace("window.__initData__ = ", "");

            JProducts = JObject.Parse(stringJson);

            var valueLinkage   = ValueLinkage();
            var valueHierarchy = ValueHierarchy();

            List <string> listItemID = ListItemID(JProducts);

            foreach (var itemID in listItemID)
            {
                var config = new ConfigXNet();
                config.AddHeaderXCSRFToken(ref request);

                var jProduct  = new JObject();
                var valueData = ValueData(itemID);
                jProduct.Add("operator", itemID);
                jProduct.Add("data", valueData);
                jProduct.Add("linkage", valueLinkage);
                jProduct.Add("hierarchy", valueHierarchy);
                var contentPost = jProduct.ToString();

                string html = request.Post("https://cart.lazada.vn/cart/api/async", contentPost, "application/json").ToString();
            }
        }
Пример #2
0
        void InteractProducts(ref HttpRequest request, Account account)
        {
            string linkref = _listLinkRef[_random.Next(0, (_listLinkRef.Count - 1))];
            bool   random  = false;

            lock (_randomAccountObj)
            {
                //Debug.WriteLine(_randomAccount, "Số account");
                if (_randomAccount == 0)
                {
                    random         = true;
                    _randomAccount = _random.Next(_randomAccountMin + 1, _randomAccountMax + 1);
                }
            }

            foreach (var item in _listLinkProducts)
            {
                request.Referer = linkref;
                Thread.Sleep(_random.Next(_timeSleepMin, _timeSleepMax + 1) * 1000);
                string linkProduct = item;
                if (linkProduct.Contains("?"))
                {
                    linkProduct = linkProduct.Split('?')[0];
                }
                var product  = new Product(linkProduct);
                var interact = new InteractProduct(product);
                interact.ViewProduct(ref request, linkProduct);
                interact.AddToWishList(ref request);
            }


            if (random)
            {
                //Debug.WriteLine(account.Email, "Add to cart");
                foreach (var item in _listLinkProducts)
                {
                    request.Referer = linkref;
                    Thread.Sleep(_random.Next(_timeSleepMin, _timeSleepMax + 1) * 1000);
                    var    config      = new ConfigXNet();
                    string linkProduct = item;
                    if (linkProduct.Contains("?"))
                    {
                        linkProduct = linkProduct.Split('?')[0];
                    }
                    var product  = new Product(linkProduct);
                    var interact = new InteractProduct(product);
                    config.AddHeaderXCSRFToken(ref request);
                    interact.AddToCart(ref request);
                }
            }
        }
Пример #3
0
        public bool IsSuccessful(ref HttpRequest request, Account account)
        {
            var config = new ConfigXNet();

            config.ConfigDefault(ref request);
            string html = request.Get("https://member.lazada.vn/user/login").ToString();

            config.AddHeaderXCSRFToken(ref request);
            string contentPost = "{\"email\":\"" + account.Email + "\",\"password\":\"" + account.Password + "\"}";

            html = request.Post("https://member.lazada.vn/user/api/login", contentPost, "application/json").ToString();
            if (html.Contains("\"success\":true"))
            {
                return(true);
            }
            return(false);
        }
Пример #4
0
        public bool AddToWishList(ref HttpRequest request)
        {
            string contentPost = "{}";
            var    configXNet  = new ConfigXNet();

            //request.Proxy = HttpProxyClient.Parse("127.0.0.1:8888");
            configXNet.AddHeaderXCSRFToken(ref request);
            //request.AddHeader("Accept", "application/json, text/plain, */*");
            //request.AddHeader("Accept Encoding", "gzip, deflate, br");
            //request.AddHeader(HttpHeader.AcceptLanguage, "vi,en-US;q=0.7,en;q=0.3");
            //request.AddHeader("X-Requested-With", "XMLHttpRequest");

            string link = "https://my.lazada.vn/wishlist/api/addItem?itemId=" + Product.ItemID + "&skuId=" + Product.SKUID;
            string html = request.Post("https://my.lazada.vn/wishlist/api/addItem?itemId=" + Product.ItemID + "&skuId=" + Product.SKUID, contentPost, "application/json;charset=utf-8").ToString();

            if (html.Contains("\"success\":true"))
            {
                return(true);
            }
            return(false);
        }
Пример #5
0
        public bool IsSuccessful(ref HttpRequest request, Account account)
        {
            var config = new ConfigXNet();

            config.ConfigDefault(ref request);
            if (EmailWasUsed(ref request, account.Email))
            {
                Debug.WriteLine(account.Email, "Trùng");
                return(false);
            }
            Thread.Sleep(3000);
            config.AddHeaderXCSRFToken(ref request);
            string contentPost = "{\"email\":\"" + account.Email + "\",\"password\":\"" + account.Password + "\",\"re-password\":\"" + account.Password + "\",\"name\":\"" + account.FullName + "\",\"enableNewsletter\":true,\"month\":\"" + account.Month + "\",\"day\":" + account.Day + ",\"year\":" + account.Year + ",\"birthday\":\"" + account.BirthDay + "\",\"gender\":\"" + account.Gender + "\",\"loading\":\"false\"}";
            //request.Proxy = HttpProxyClient.Parse("127.0.0.1:8888");
            string html = request.Post("https://member.lazada.vn/user/api/register", contentPost, "application/json").ToString();

            if (html.Contains("\"success\":true"))
            {
                return(true);
            }
            return(false);
        }
Пример #6
0
        void RunJOB(Account account, string port, string userAgent)
        {
            HttpRequest request    = new HttpRequest();
            var         configXNet = new ConfigXNet();

            configXNet.AddUserAgent(ref request, userAgent);
            var login = new LoginAccount();

            if (login.IsSuccessful(ref request, account))
            {
                foreach (var item in _listLinkProducts)
                {
                    string linkProduct = item;
                    if (linkProduct.Contains("?"))
                    {
                        linkProduct = linkProduct.Split('?')[0];
                    }
                    var product  = new Product(linkProduct);
                    var interact = new InteractProduct(product);
                    interact.ViewProduct(ref request, linkProduct);
                    interact.AddToWishList(ref request);
                }
            }
        }
Пример #7
0
        //bool Login(Account account, ref HttpRequest request, string port, string useAgent)
        //{

        //    SettingsRequest(ref request, useAgent);

        //    string html = request.Get("https://www.lazada.vn/customer/account/login/").ToString();
        //    var info = new ProductInfo(html);
        //    request.AddParam("FORM_TOKEN", info.FormToken());
        //    request.AddParam("referer", "https://www.lazada.vn/");
        //    request.AddParam("LoginForm[email]", account.Email);
        //    request.AddParam("LoginForm[password]", account.Password);
        //    Thread.Sleep(THREAD_SLEEP_FAST);
        //    html = request.Post("https://www.lazada.vn/customer/account/login/").ToString();
        //    html = request.Get("https://www.lazada.vn/customer/account/").ToString();
        //    if (html.Contains("Quản lý tài khoản"))
        //        return true;
        //    return false;

        //}

        void JobRegister(Account account, string port, string userAgent)
        {
            HttpRequest request    = new HttpRequest();
            var         configXNet = new ConfigXNet();

            configXNet.AddUserAgent(ref request, userAgent);

            try
            {
                using (var client = new SshClient(account.IP, 22, account.UsernameIP, account.PasswordIP))
                {
                    // timeout 30s
                    client.ConnectionInfo.Timeout = TimeSpan.FromSeconds(25);
                    client.ErrorOccurred         += (se, ev) => { };
                    client.KeepAliveInterval      = TimeSpan.FromSeconds(60);
                    client.Connect();

                    if (client.IsConnected)
                    {
                        var forwarder = new ForwardedPortDynamic("127.0.0.1", Convert.ToUInt32(port));
                        forwarder.Exception += (se, ev) => { };
                        client.AddForwardedPort(forwarder);

                        forwarder.Start();
                        request.Proxy = HttpProxyClient.Parse(ProxyType.Socks5, "127.0.0.1:" + port);

                        var register = new RegisterAccount();

                        if (register.IsSuccessful(ref request, account))
                        {
                            lock (_randomAccountObj)
                            {
                                _randomAccount--;
                                var export = new ExportResult();
                                export.FileResult(_fileResultPath, account);
                                rtxtResult.Text += account.Email + " | " + account.Password + Environment.NewLine;
                            }

                            InteractProducts(ref request, account);

                            //Debug.WriteLine(account.Email, "Xong");
                        }
                        else
                        {
                            //Debug.WriteLine(account.Email, "Lỗi");
                            var export = new ExportResult();
                            lock (_fileErrorObj)
                                export.FileResult(_fileErrorPath, account);
                        }
                    }
                    else
                    {
                        //Debug.WriteLine(account.Email, "Lỗi SSH");
                        var export = new ExportResult();
                        lock (_fileErrorObj)
                            export.FileResult(_fileErrorPath, account);
                    }
                }
            }
            catch
            {
                //Debug.WriteLine(account.Email, "Lỗi SSH");
                var export = new ExportResult();
                lock (_fileErrorObj)
                    export.FileResult(_fileErrorPath, account);
            }
        }
Пример #8
0
        void JobLikeProduct(Account account, string port, string userAgent)
        {
            HttpRequest request    = new HttpRequest();
            var         configXNet = new ConfigXNet();

            configXNet.AddUserAgent(ref request, userAgent);

            try
            {
                using (var client = new SshClient(account.IP, 22, account.UsernameIP, account.PasswordIP))
                {
                    // timeout 30s
                    client.ConnectionInfo.Timeout = TimeSpan.FromSeconds(25);
                    client.ErrorOccurred         += (se, ev) => { };
                    client.KeepAliveInterval      = TimeSpan.FromSeconds(60);
                    client.Connect();

                    if (client.IsConnected)
                    {
                        var forwarder = new ForwardedPortDynamic("127.0.0.1", Convert.ToUInt32(port));
                        forwarder.Exception += (se, ev) => { };
                        client.AddForwardedPort(forwarder);

                        forwarder.Start();
                        request.Proxy = HttpProxyClient.Parse(ProxyType.Socks5, "127.0.0.1:" + port);

                        var login = new LoginAccount();

                        if (login.IsSuccessful(ref request, account))
                        {
                            if (_removeProduct)
                            {
                                var remove = new RemoveProduct();
                                remove.Remove(ref request);
                            }

                            lock (_fileResultObj)
                            {
                                _randomAccount--;
                                rtxtResult.Text += account.Email + " | " + account.Password + Environment.NewLine;
                            }

                            InteractProducts(ref request, account);
                        }
                        else
                        {
                            var export = new ExportResult();
                            lock (_fileErrorObj)
                            {
                                export.FileResult(_fileErrorPath, account);
                                rtxtResult.Text += account.Email + " | " + account.Password + " | Lỗi không đăng nhập được" + Environment.NewLine;
                            }
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }
            catch
            {
                var export = new ExportResult();
                lock (_fileErrorObj)
                {
                    export.FileResult(_fileErrorPath, account);
                    rtxtResult.Text += account.Email + " | " + account.Password + " | Lỗi không đăng nhập được" + Environment.NewLine;
                }
                return;
            }
        }