Exemple #1
0
        /// <summary>
        /// 比较新品并上架
        /// </summary>
        /// <returns></returns>
        public bool CarepareAndUpItem()
        {
            BaseReadWebPage newItem    = new BaseReadWebPage();
            BaseReadWebPage downItem   = new BaseReadWebPage();
            BaseReadWebPage onlineItem = new BaseReadWebPage();

            newItem.ReadBaseItemInfo("TK/低于20以上.csv", true);
            downItem.ReadBaseItemInfo("TKAdmin/down.csv", true);
            onlineItem.ReadBaseItemInfo("TKAdmin/TKAdmin.csv", true);

            Http.HttpRequest http = new Http.HttpRequest();
            http.CookieContainer = Login();

            foreach (string key in newItem.ShopAllItems.Keys)
            {
                if (onlineItem.ShopAllItems.ContainsKey(key))
                {
                    continue;
                }

                if (downItem.ShopAllItems.ContainsKey(key))
                {
                    downItem.ShopAllItems[key].ShopPrice = newItem.ShopAllItems[key].ShopPrice;
                    ReUpItem(downItem.ShopAllItems[key], http);
                    CommonFun.WriteCSV("TKAdmin/need_reUp.csv", downItem.ShopAllItems[key]);
                    continue;
                }

                UpNewItem(newItem.ShopAllItems[key], http);

                CommonFun.WriteCSV("TKAdmin/new" + fileName + ".csv", newItem.ShopAllItems[key]);
            }

            return(true);
        }
Exemple #2
0
        public bool UpAllNewItme()
        {
            BaseReadWebPage newItem = new BaseReadWebPage();

            newItem.ReadBaseItemInfo("TKAdmin/new.csv", true);

            Http.HttpRequest http = new Http.HttpRequest();

            int totalCount = newItem.ShopAllItems.Count;

            int curCount = 0;

            foreach (BaseItemInfo item in newItem.ShopAllItems.Values)
            {
                if (curCount % 100 == 0)
                {
                    http.CookieContainer = Login();
                }

                UpNewItem(item, http);

                curCount++;

                Console.WriteLine("{0}:UpNewItem,TotalCount{1}, curCount:{2}", DateTime.Now, totalCount, curCount);
            }

            return(true);
        }
Exemple #3
0
        /// <summary>
        /// 下架物品
        /// </summary>
        /// <returns></returns>
        public bool DownItem()
        {
            GetWebPageDate.Http.HttpRequest http = new GetWebPageDate.Http.HttpRequest();

            http.Cookie = "Hm_lvt_ed70f863f631ecaac146592025767ed8=1509785002; Qs_lvt_150743=1509785002; Qs_pv_150743=3457133030228596700; NTKF_T2D_CLIENTID=guestTEMP1758-0E75-6A74-9EB9-8632DF7CEB19; acw_tc=AQAAALQugFvwMw4A3eT4OjtYTVthFUKH; PHPSESSID=cvbcvjhi3a70qu9drah6l31ht0; sellerCooke=think%3A%7B%22sellerName%22%3A%22hankang%22%2C%22sellerStoreName%22%3A%22%25E9%2595%25BF%25E6%25B2%2599%25E5%258E%25BF001%25E5%25BA%2597%22%7D; Hm_lvt_7203bc79de07054ef3770e27e8ca9068=1509780503,1509934350,1510060776; Hm_lpvt_7203bc79de07054ef3770e27e8ca9068=1510061193";

            string downUrl = "https://admin.tkyfw.com/Goods/edit_dowmGoods";

            BaseReadWebPage res = new BaseReadWebPage();

            res.ReadBaseItemInfo("TKAdmin/NotEixst.csv", true);

            BaseReadWebPage res1 = new BaseReadWebPage();

            res1.ReadBaseItemInfo("TKAdmin/低于20以上.csv", true);
            string postData = "storeid={0}&off_the_shelf=";

            int curCount = 0;

            int totalCount = res.ShopAllItems.Count + res1.ShopAllItems.Count;

            //foreach(BaseItemInfo item in res.ShopAllItems.Values)
            //{
            //    Console.WriteLine("curCount:{0}, totalCount:{1}", curCount++, totalCount);
            //    http.HttpPost(downUrl, string.Format(postData, item.ViewCount));
            //}

            foreach (BaseItemInfo item in res1.ShopAllItems.Values)
            {
                Console.WriteLine("curCount:{0}, totalCount:{1}", curCount++, totalCount);
                http.HttpPost(downUrl, string.Format(postData, item.ViewCount));
            }

            return(true);
        }
        public void ComparePrice()
        {
            ReadPlatFormWebPageValue flatform = new ReadPlatFormWebPageValue();
            BaseReadWebPage          res      = new BaseReadWebPage();
            BaseReadWebPage          target   = new BaseReadWebPage();

            target.ReadBaseItemInfo("YaoTu/YaoTu636500822100643979.csv", true);
            res.ReadBaseItemInfo("YaoTu/Plateform636500822100643979.csv", true);

            foreach (BaseItemInfo item in target.ShopAllItems.Values)
            {
                foreach (BaseItemInfo platformItem in res.ShopAllItems.Values)
                {
                    if ((item.Name == platformItem.Name && item.Created == platformItem.Created))
                    {
                        if (CommonFun.IsSameFormat(platformItem.Format, item.Format, platformItem.Name, item.Name))
                        {
                            //浏览量对比
                            //if (!string.IsNullOrEmpty(platformItem.ViewCount) && Convert.ToInt32(platformItem.ViewCount) >= 500)
                            //{

                            if (platformItem.ShopSelaPrice * (decimal)0.75 >= item.ShopPrice)
                            {
                                item.ID            = platformItem.ID;
                                item.ShopSelaPrice = platformItem.ShopSelaPrice;
                                item.Type          = platformItem.Type;
                                item.ViewCount     = platformItem.ViewCount;

                                CommonFun.WriteCSV("YaoTu/25%_" + ticks + ".csv", item);
                            }
                            else if (platformItem.ShopSelaPrice * (decimal)0.8 >= item.ShopPrice)
                            {
                                item.ID            = platformItem.ID;
                                item.ShopSelaPrice = platformItem.ShopSelaPrice;
                                item.Type          = platformItem.Type;
                                item.ViewCount     = platformItem.ViewCount;

                                CommonFun.WriteCSV("YaoTu/20%_" + ticks + ".csv", item);
                            }
                            else if (platformItem.ShopSelaPrice * (decimal)0.85 >= item.ShopPrice)
                            {
                                item.ID            = platformItem.ID;
                                item.ShopSelaPrice = platformItem.ShopSelaPrice;
                                item.Type          = platformItem.Type;
                                item.ViewCount     = platformItem.ViewCount;

                                CommonFun.WriteCSV("YaoTu/15%_" + ticks + ".csv", item);
                            }
                            //}
                        }
                    }
                }
            }
        }
Exemple #5
0
        public bool ReUpItemByCSV(string fileName)
        {
            try
            {
                Http.HttpRequest http = new Http.HttpRequest();

                BaseReadWebPage newItem      = new BaseReadWebPage();
                BaseReadWebPage downItemList = new BaseReadWebPage();

                newItem.ReadBaseItemInfo(fileName, true);
                downItemList.ReadBaseItemInfo("TKAdmin/down.csv", true);

                int count = 0;

                foreach (BaseItemInfo item in newItem.ShopAllItems.Values)
                {
                    foreach (BaseItemInfo downItem in downItemList.ShopAllItems.Values)
                    {
                        if (item.ID == downItem.ID)
                        {
                            if (count % 100 == 0)
                            {
                                http.CookieContainer = Login();
                            }

                            count++;

                            downItem.ShopPrice = downItem.PlatformPrice;

                            ReUpItem(downItem, http);

                            Thread.Sleep(random.Next(3, 6) * 1000);

                            break;
                        }
                    }
                }

                Console.WriteLine("UpItem count:{0}", count);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(true);
        }
Exemple #6
0
        /// <summary>
        /// 重新上架所有物品
        /// </summary>
        /// <returns></returns>
        public bool ReUpAllItem()
        {
            BaseReadWebPage newItem = new BaseReadWebPage();

            Http.HttpRequest http = new Http.HttpRequest();

            http.CookieContainer = Login();

            newItem.ReadBaseItemInfo("TKAdmin/need_reUp.csv", true);

            foreach (BaseItemInfo item in newItem.ShopAllItems.Values)
            {
                ReUpItem(item, http);
            }

            return(true);
        }
Exemple #7
0
        /// <summary>
        /// 本地文件中获取在售列表
        /// </summary>
        /// <returns></returns>
        public Dictionary <string, BaseItemInfo> GetSellingItem()
        {
            Dictionary <string, BaseItemInfo> items = new Dictionary <string, BaseItemInfo>();

            BaseReadWebPage read = new BaseReadWebPage();

            read.ReadBaseItemInfo("TKAdmin/TKAdmin.csv", true);

            foreach (BaseItemInfo item in read.ShopAllItems.Values)
            {
                string key = item.ID + item.Format;
                if (!items.ContainsKey(key))
                {
                    items.Add(key, item);
                }
                else
                {
                    Console.WriteLine("Have same item id:{0},format:{1}", item.ID, item.Format);
                }
            }

            return(items);
        }
Exemple #8
0
        /// <summary>
        /// 上架新品
        /// </summary>
        public void UpNewItem()
        {
            Login();

            BaseReadWebPage read = new BaseReadWebPage();

            read.ReadBaseItemInfo("TYaoFang/20以上636493584245833259--------------.csv", true);

            int count = 0;

            foreach (BaseItemInfo item in read.ShopAllItems.Values)
            {
                try
                {
                    if (count++ % 200 == 0)
                    {
                        Login();
                    }

                    int startIndex = item.ID.IndexOf('字');
                    startIndex = (startIndex > 0 ? startIndex : item.ID.IndexOf('号')) + 1;
                    string id = item.ID.Substring(startIndex, item.ID.Length - startIndex);

                    // 查找商品模板
                    string seachUrl    = "http://www.12yao.com/pharmacy/ajax_productinfo.php";
                    string postDataStr = "action=getProductSearch&keywords={0}&searchType=1";

                    string data = string.Format(postDataStr, id);

                    string          content = request.HttpPost(seachUrl, data, "http://www.12yao.com/pharmacy/productRelease.php?rootID=1", null, Encoding.GetEncoding("gb2312"));
                    MatchCollection ms      = CommonFun.GetValues(content, "<li>", "</li>");

                    foreach (Match m in ms)
                    {
                        //对比格式
                        string format = CommonFun.GetValue(m.Value, "<b>", "</b>");

                        if (format == item.Format)
                        {
                            string productID       = CommonFun.GetValue(m.Value, "value='", "'");
                            string postDataStrInfo = "action=getProductInfo&ProductID={0}";

                            content = request.HttpPost(seachUrl, string.Format(postDataStrInfo, productID));
                            // 保存价格数据
                            string saveUrl = "http://www.12yao.com/pharmacy/SaveProduct.php";

                            string postDataSave = "PreferentialPrice={1}&RetailPrice={1}&ProductStock={2}&Weight=6&ProductCode={0}&standardCode=&REPID=&Base_ProductID={0}&action=addproductrelease&Submit=%CB%D1%CB%F7";
                            Random random       = new Random((int)DateTime.Now.Ticks);
                            content = request.HttpPost(saveUrl, string.Format(postDataSave, productID, item.PlatformPrice, random.Next(30, 40)));

                            //获取待上架列表
                            string willUpUrl = string.Format("http://www.12yao.com/pharmacy/ProductUnderFrameList.php?ProductName=&ReasonShelves=0&ProductBatch={0}&CompanyTitle=&ProductCode=&ProductType=0&time1=&time2=", HttpUtility.UrlEncode(item.ID, Encoding.GetEncoding("gb2312")).ToUpper());

                            content = request.HttpGet(willUpUrl, null, Encoding.GetEncoding("gb2312"));

                            bool isUp = false;

                            if (!string.IsNullOrEmpty(content))
                            {
                                MatchCollection upIdMs = CommonFun.GetValues(content, " <tr id=\"", " </tr>");

                                foreach (Match upIdM in upIdMs)
                                {
                                    string willUpFormat = CommonFun.GetValue(upIdM.Value, "<td class=\"dgui\">", "</td>");

                                    if (willUpFormat == item.Format)
                                    {
                                        string upId = CommonFun.GetValue(upIdM.Value, " value=\"", "\"");

                                        // 上架商品
                                        string upUrl = "http://www.12yao.com/pharmacy/ProductsUnderFrame.php";

                                        string postDataUp = "SelectPid={0}&action=setMultipleProductUpFrame";

                                        string reuslt = request.HttpPost(upUrl, string.Format(postDataUp, upId));

                                        isUp = true;
                                    }
                                }
                            }

                            if (!isUp)
                            {
                                CommonFun.WriteCSV("TYaoFang/faild" + tick + ".csv", item);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    CommonFun.WriteCSV("TYaoFang/faild" + tick + ".csv", item);
                    Console.WriteLine(ex);
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// 数据对比
        /// </summary>
        public void Compare()
        {
            ReadPlatFormWebPageValue flatform = new ReadPlatFormWebPageValue();
            BaseReadWebPage          platform = new BaseReadWebPage();
            BaseReadWebPage          shop     = new BaseReadWebPage();

            platform.ReadBaseItemInfo("Platform/Platform636488666326049889.csv", true);
            shop.ReadBaseItemInfo("TYaoFang/NotIsEixst636493584245833259.csv", true);

            foreach (BaseItemInfo item in shop.ShopAllItems.Values)
            {
                bool   isEixst  = false;
                string itemName = item.Name;

                if (item.Name.Contains("】"))
                {
                    int itemNameIndex = item.Name.LastIndexOf("】") + 1;
                    itemName = item.Name.Substring(itemNameIndex, item.Name.Length - itemNameIndex);
                }

                if (itemName.Contains("("))
                {
                    int itemNameIndex = itemName.IndexOf('(');

                    itemName = itemName.Substring(0, itemNameIndex);
                }

                foreach (BaseItemInfo platformItem in platform.ShopAllItems.Values)
                {
                    bool isSame = false;
                    if (!string.IsNullOrEmpty(item.ID) && !string.IsNullOrEmpty(platformItem.ID))
                    {
                        if (item.ID.Trim() == platformItem.ID.Trim())
                        {
                            isSame = true;
                        }
                    }


                    if (isSame || (itemName == platformItem.Name && item.Created == platformItem.Created))
                    {
                        if (CommonFun.IsSameFormat(platformItem.Format, item.Format, platformItem.Name, item.Name))
                        {
                            isEixst = true;
                            if (ComparePrice(platformItem, item))
                            {
                                break;
                            }
                        }
                    }
                }

                //if (!isEixst)
                //{
                //    List<BaseItemInfo> seachItems = flatform.SeachInfoByID(item.ID);

                //    Dictionary<string, BaseItemInfo> saveInfos = new Dictionary<string, BaseItemInfo>();

                //    foreach (BaseItemInfo info in seachItems)
                //    {
                //        string key = info.Name + info.Format + info.Created;

                //        if (!platform.ShopAllItems.ContainsKey(key))
                //        {
                //            if (item.ID == info.ID || (itemName == info.Name && item.Created == info.Created))
                //            {
                //                if (CommonFun.IsSameFormat(info.Format, item.Format, info.Name, item.Name))
                //                {
                //                    isEixst = true;
                //                    ComparePrice(info, item);
                //                }
                //            }

                //            platform.ShopAllItems.Add(key, info);
                //            saveInfos.Add(key, info);
                //        }
                //        else if (platform.ShopAllItems[key].ShopSelaPrice > info.ShopSelaPrice)
                //        {
                //            if (item.ID == info.ID || (itemName == info.Name && item.Created == info.Created))
                //            {
                //                if (CommonFun.IsSameFormat(info.Format, item.Format, info.Name, item.Name))
                //                {
                //                    isEixst = true;
                //                    ComparePrice(info, item);
                //                }
                //            }

                //            platform.ShopAllItems[key] = info;
                //            saveInfos[key] = info;
                //        }
                //    }

                //    foreach (BaseItemInfo saveInfo in saveInfos.Values)
                //    {
                //        CommonFun.WriteCSV("Platform/Platform636488666326049889.csv", saveInfo);
                //    }
                //}

                if (!isEixst)
                {
                    CommonFun.WriteCSV("TYaoFang/NotIsEixst" + tick + ".csv", item);
                }
            }
        }