Beispiel #1
0
        /// <summary>
        /// 获取在售列表
        /// </summary>
        /// <param name="http"></param>
        /// <returns></returns>
        public Dictionary <string, BaseItemInfo> GetSellingItem(Http.HttpRequest http)
        {
            Dictionary <string, BaseItemInfo> items = new Dictionary <string, BaseItemInfo>();

            string url = "https://admin.tkyfw.com/Goods/throughAudit?/Goods/throughAudit=&status=1&state=1";

            string content = http.HttpGet(url);

            string itemStr = CommonFun.GetValue(content, "<form name=\"form\" method=\"post\">", "</form>");

            List <BaseItemInfo> temp = GetOnePageItems(itemStr);

            string pageStr = CommonFun.GetValue(content, "下一页", "><span>末页</span>");

            pageStr = CommonFun.GetValue(pageStr, "&p=", "\"");
            pageStr = pageStr.Substring(pageStr.LastIndexOf("=") + 1);

            int totalPage = 0;

            if (!string.IsNullOrEmpty(pageStr))
            {
                totalPage = Convert.ToInt32(pageStr);
            }

            for (int i = 2; i <= totalPage; i++)
            {
                content = http.HttpGet("https://admin.tkyfw.com/Goods/throughAudit?/Goods/throughAudit=&status=1&state=1&p=" + i);

                itemStr = CommonFun.GetValue(content, "<form name=\"form\" method=\"post\">", "</form>");

                temp.AddRange(GetOnePageItems(itemStr));

                Console.WriteLine("{0}:GetSelling totalPage:{1}, curPage{2}.....", DateTime.Now, totalPage, i);
            }

            foreach (BaseItemInfo item in temp)
            {
                string key = item.ID + item.Format;

                if (!items.ContainsKey(key))
                {
                    items.Add(key, item);
                }
                else
                {
                    Console.WriteLine("Error, Same Itme key:{0}", key);
                }
            }

            return(items);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        /// <summary>
        /// 获取订单列表
        /// </summary>
        /// <returns></returns>
        public string GetOrderList(Http.HttpRequest http)
        {
            string url = "https://admin.tkyfw.com/Order/turn_out_pool";

            string content = http.HttpGet(url);

            return(content);
        }
Beispiel #4
0
        /// <summary>
        /// 获取平台最低价
        /// </summary>
        /// <param name="id"></param>
        /// <param name="format"></param>
        /// <param name="http"></param>
        /// <returns></returns>
        public decimal GetPlatformPrice(string id, string format, Http.HttpRequest http, bool isSameOther = false)
        {
            try
            {
                decimal price = decimal.MaxValue;

                decimal otherPrice = decimal.MaxValue;

                int changeNum = 0;

                string url = string.Format("https://www.tkyfw.com/Ching_search.html?keyword={0}", id);

                string content = http.HttpGet(url);

                content = CommonFun.GetValue(content, "<ul class=\"seach_list\">", "</ul>");

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

                foreach (Match m in ms)
                {
                    string item_format = CommonFun.GetValue(m.Value, "规格:", "</p>");

                    if (item_format == format)
                    {
                        MatchCollection urlMs = CommonFun.GetValues(m.Value, "<a href=\"", "\"");

                        content = http.HttpGet("https://www.tkyfw.com" + urlMs[0].Value);

                        MatchCollection itemMs = CommonFun.GetValues(content, "<div class=\"merinfo\">", "</label>");

                        foreach (Match itemM in itemMs)
                        {
                            string priceStr = CommonFun.GetValue(itemM.Value, "¥", "</p>");
                            string shopInfo = CommonFun.GetValue(itemM.Value, "市<span>-</span>", "</a>");
                            try
                            {
                                if (!string.IsNullOrEmpty(priceStr))
                                {
                                    decimal temp = Convert.ToDecimal(priceStr);
                                    if (temp != price)
                                    {
                                        changeNum++;
                                    }
                                    if (isSameOther && shopInfo == other_store_name)
                                    {
                                        otherPrice = temp;
                                        break;
                                    }
                                    else if (shopInfo != store_name)
                                    {
                                        if (temp < price)
                                        {
                                            price = temp;
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex);
                            }
                        }

                        break;
                    }
                }

                if (otherPrice != decimal.MaxValue)
                {
                    return(otherPrice);
                }
                else
                {
                    //if (changeNum == 1)
                    //{
                    //    return price;
                    //}
                    return(price);
                    //if (price != decimal.MaxValue)
                    //{
                    //    return (price - (decimal)0.01);
                    //}
                    //else
                    //{
                    //    return price;
                    //}
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            return(decimal.MaxValue);

            //return otherPrice != decimal.MaxValue ? otherPrice : (price - (decimal)0.01);
        }