Beispiel #1
0
        /// <summary>
        /// 上架新物品
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool UpNewItem(BaseItemInfo item, Http.HttpRequest http)
        {
            if (item.ShopPrice < 5)
            {
                return(false);
            }
            //find
            string findUrl      = "https://admin.tkyfw.com/Goods/findExp";
            string findPostData = "store_id=34";

            http.HttpPost(findUrl, findPostData);

            //findApp
            string findAppUrl      = "https://admin.tkyfw.com/Goods/findAppNum";
            string findAppPostData = string.Format("appNum:{0}", item.ID);

            http.HttpPost(findAppUrl, findAppPostData);

            string url = string.Format("https://admin.tkyfw.com/Goods/complateInfo?cat_first=&cat_second=&cat_third=&approval_number={0}", item.ID);

            string upNewItemUrl = "https://admin.tkyfw.com/Goods/findRepeatCheck";

            string checkUrl = "https://admin.tkyfw.com/Goods/checkGoods";

            string content = http.HttpGet(url);


            MatchCollection ms = CommonFun.GetValues(content, "gxtj_ul", "</li>");

            foreach (Match m in ms)
            {
                string fromat = CommonFun.GetValue(m.Value, "<span>", "<span>");

                fromat = CommonFun.FormatStr(fromat, item.Name);

                if (fromat == item.Format)
                {
                    string boxStr = CommonFun.GetValue(m.Value, "\"checkbox\"", "/>");

                    string value = CommonFun.GetValue(boxStr, "value=\"", "\"");

                    string result = http.HttpPost(upNewItemUrl, string.Format("value_arr={0}{1}", value, HttpUtility.UrlEncode(",")));

                    result = CommonFun.GetValue(result, ":", "}");

                    if (result == "2")
                    {
                        CommonFun.WriteCSV("TKAdmin/UpNew" + fileName + ".csv", item);
                        http.HttpPost(checkUrl, "", url, "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8", null);
                        Console.WriteLine("UpNewItem,name:{0}, id:{1}, fromat:{2}", item.Name, item.ID, item.Format);
                    }
                    Thread.Sleep(random.Next(3, 6) * 1000);


                    // UpdatePrice(item, http);
                }
            }

            return(true);
        }