Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            // Please keep in mind that you must not use special characters (includes ä, ö, ü etc.)
            // Except " " in info.fullName, info.address_1, .._2, .._3, info.city
            // Except "@" in info.email
            // Except "+" in info.telephone

            billingInfo info = new billingInfo();

            info.creditcard  = Creditcards.VISA;
            info.fullname    = "Max Mustermann";
            info.email       = "*****@*****.**";
            info.telephone   = "+4915113371337";
            info.address_1   = "12 Muehlen Street";
            info.address_2   = "Bldg E";
            info.address_3   = "Floor 2 Apt 12";
            info.zip         = "78467";
            info.city        = "Konstanz";
            info.countryCode = "DE";
            info.ccNumber    = "4906759104921149";
            info.ccMonth     = "12";
            info.ccYear      = "2019";
            info.ccCVV       = "999";

            String keywords = "lacoste,track,jacket";
            String color    = "black";
            String size     = "Medium";


            List <String> urlList  = retrieveShopList();
            cartInfo      realInfo = retrieveSpecificUrl(urlList, Categories.All, keywords, true, color, true, size);

            if (realInfo.articleID != "article_sold_out" && realInfo.articleID != "article_not_found")
            {
                if (addToCart(realInfo))
                {
                    // Added to Cart
                    if (checkOut(info))
                    {
                        // Checked out successfully. Order placed.
                    }
                    else
                    {
                        // Error checking out
                    }
                }
                else
                {
                    // Error  adding to cart
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Adds the item to cart.
        /// </summary>
        /// <param name="info">Structure with information about the corresponding item</param>
        /// <returns>Returns true if adding to cart was successful, false if not. (maybe sold out)</returns>
        private static bool addToCart(cartInfo info)
        {
            String         postString = "utf8=" + cartInfo.UTF8 + "&style=" + info.styleID + "&size=" + info.sizeID + "&commit=" + cartInfo.en_commit;
            HttpWebRequest req        = (HttpWebRequest)WebRequest.Create("http://supremenewyork.com/shop/" + info.articleID + "/add");

            req.CookieContainer   = cookies;
            req.Method            = "POST";
            req.ContentType       = "application/x-www-form-urlencoded";
            req.ContentLength     = postString.Length;
            req.AllowAutoRedirect = false;
            req.Referer           = info.referer;
            req.Headers["Upgrade-Insecure-Requests"] = "1";
            req.Host = "www.supremenewyork.com";

            StreamWriter writePost = new StreamWriter(req.GetRequestStream());

            writePost.Write(postString);
            writePost.Close();

            HttpWebResponse res = (HttpWebResponse)req.GetResponse();

            StreamReader readResponse  = new StreamReader(res.GetResponseStream());
            String       finalResponse = readResponse.ReadToEnd();

            readResponse.Close();


            req                   = (HttpWebRequest)WebRequest.Create("http://supremenewyork.com/shop/cart");
            req.Method            = "GET";
            req.AllowAutoRedirect = true;
            req.CookieContainer   = cookies;

            readResponse  = new StreamReader(req.GetResponse().GetResponseStream());
            finalResponse = readResponse.ReadToEnd();
            readResponse.Close();

            if (finalResponse.Contains("1 item"))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }