Exemple #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);
        }
Exemple #2
0
        private List <BaseItemInfo> GetSomeItem(string content)
        {
            List <BaseItemInfo> items = new List <BaseItemInfo>();

            if (!string.IsNullOrEmpty(content))
            {
                MatchCollection ms = CommonFun.GetValues(content, "<row>", "</row>");

                foreach (Match m in ms)
                {
                    try
                    {
                        BaseItemInfo item = new BaseItemInfo();
                        item.ViewCount = CommonFun.GetValue(m.Value, "<ARTID>", "</ARTID>");
                        item.Name      = CommonFun.GetValue(m.Value, "<NAME>", "</NAME>");
                        item.Format    = CommonFun.GetValue(m.Value, "<SPEC>", "</SPEC>");
                        item.Created   = CommonFun.GetValue(m.Value, "<FACTORY>", "</FACTORY>");
                        item.ID        = CommonFun.GetValue(m.Value, "<FILENO>", "</FILENO>");
                        string priceStr = CommonFun.GetValue(m.Value, "<PRICE>", "</PRICE>");
                        item.PlatformPrice = string.IsNullOrEmpty(priceStr) ? 0 : Convert.ToDecimal(priceStr);
                        item.Type          = CommonFun.GetValue(m.Value, "<MEDIATYPENAME>", "</MEDIATYPENAME>");
                        items.Add(item);

                        AddItme(item, "HA/HA" + ticks + ".csv");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                }
            }
            return(items);
        }
        public override void ReadAllMenuURL()
        {
            try
            {
                string url = "http://ad.dabai.7lk.com/findMedication/patCategories";

                string postData = "doctorId=321967&userId=321967&token=9d571f1dc32cadf0ea38";

                string content = request.HttpPost(url, postData);

                MatchCollection ms = CommonFun.GetValues(content, "\"children\":", "\"sortable\":");

                foreach (Match m in ms)
                {
                    MatchCollection mMs = CommonFun.GetValues(m.Value, "{", "}");

                    foreach (Match mM in mMs)
                    {
                        string pMenuName = CommonFun.GetValue(mM.Value, "\"parent\":\"", "\"");
                        string sMenuName = CommonFun.GetValue(mM.Value, "\"title\":\"", "\"");
                        Console.WriteLine("pMenuName:{0}, sMenuName:{1}", pMenuName, sMenuName);
                        string menuData = string.Format("doctorId=321967&firTitle={0}&orderBy=default&secTitle={1}&userId=321967&token=9d571f1dc32cadf0ea38", HttpUtility.UrlEncode(pMenuName), HttpUtility.UrlEncode(sMenuName));
                        if (!AllMenuUrl.Contains(menuData))
                        {
                            AllMenuUrl.Add(menuData);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Exemple #4
0
        /// <summary>
        /// 是否可以接
        /// </summary>
        /// <returns></returns>
        public bool CanTake(string content, Http.HttpRequest http)
        {
            string infoStr = CommonFun.GetValue(content, "<tr>", "</tr>");

            MatchCollection tdMs = CommonFun.GetValues(infoStr, "<td>", "</td>");

            string orderNO = CommonFun.GetValue(infoStr, "<td class=\"tablenow\">", "</td>");

            bool result = false;

            MatchCollection ms = CommonFun.GetValues(content, "<div class=\"tkzds\">", "</div>");

            string format = ms[0].Value;
            string id     = ms[1].Value;
            string key    = id + format;

            //是否TK平台的单
            if (orderNO.StartsWith("TK") && !IsSelfOrder(content))
            {
                string drs = tdMs[5].Value;
                //不是同城
                if (!drs.Contains("长沙"))
                {
                    BaseItemInfo item = items.ContainsKey(key) ? items[key] : null;

                    //在线支付
                    if (infoStr.Contains("在线支付") || (infoStr.Contains("货到付款") && item != null && item.Type == "201"))
                    {
                        string msg    = CommonFun.GetValue(content, "<li>买家留言:<span>", "</span></li>");
                        string remark = CommonFun.GetValue(content, "<li>平台备注:<span>", "</span></li>");
                        //无需发票
                        if (!msg.Contains("发票") && !remark.Contains("发票"))
                        {
                            //MatchCollection ms = CommonFun.GetValues(content, "<div class=\"tkzds\">", "</div>");
                            //单品
                            if (ms.Count == 5)
                            {
                                //ms = CommonFun.GetValues(content, "span1 xiatiaomar\">", "</div>");
                                decimal price = Convert.ToDecimal(ms[2].Value);

                                //价格合理
                                if (items.ContainsKey(key))
                                {
                                    if (true || items[key].PlatformPrice <= price)
                                    {
                                        result = true;
                                    }
                                    else
                                    {
                                        Console.WriteLine("Price info orderPrice:{0}, sellPrice:{1}", price, items[key].PlatformPrice);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(result);
        }
Exemple #5
0
        /// <summary>
        /// 修改所有在售物品的价格
        /// </summary>
        /// <returns></returns>
        public bool UpdateAllSellingItemPrice(string itemStr, GetWebPageDate.Http.HttpRequest http, decimal upParam = 1)
        {
            itemStr = itemStr.Replace('\n', ' ');
            itemStr = itemStr.Replace('\t', ' ');
            MatchCollection ms = CommonFun.GetValues(itemStr, "<div class=\"tkprolistbox\">", "修改");

            foreach (Match m in ms)
            {
                ItemInfo item = GetOneItem(m.Value);

                string tag = CommonFun.GetValue(m.Value, "promotionEd=\"", "\"");

                decimal price = GetPlatformPrice(item.ID, item.Format, http);

                string info = "";

                if (item.Type != "333" && price != decimal.MaxValue && item.PlatformPrice != price)
                {
                    info = UpdatePrice(http, price * upParam, item.ViewCount, item.Type, item.Inventory);

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

                    if (info != "1")
                    {
                        string priceStr = CommonFun.GetValue(info, ":\"", "\"");

                        price = 0;

                        try
                        {
                            price = Convert.ToDecimal(priceStr);
                            if (price != 1)
                            {
                                price = (decimal)((double)price - 0.01);
                            }
                            else
                            {
                                price = GetItemPrice(item);
                            }
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex);
                        }

                        if (price != item.PlatformPrice)
                        {
                            UpdatePrice(http, price, item.ViewCount, tag, item.Inventory);
                        }
                    }
                }
                item.ShopPrice = price;
                CommonFun.WriteCSV("TKAdmin/TKAdmin" + fileName + ".csv", item);
            }
            return(true);
        }
        private void GetOnePageBaseItemInfo(string content)
        {
            MatchCollection ms = CommonFun.GetValues(content, "<div class=\"desc\">", "<div class=\"other\">");

            foreach (Match m in ms)
            {
                if (m.Value.Contains("noprice"))
                {
                    return;
                }

                string priceStr = CommonFun.GetValue(m.Value, "</small>", "</span>");

                if (string.IsNullOrEmpty(priceStr))
                {
                    Console.WriteLine("Login failed!!!!");
                    request.Cookie = "__jsluid=00722fe4a2305a1f7e6e44e846a302ce; ASP.NET_SessionId=nmfxaoaonht2wzmiafye2w4v; Hm_lvt_3f534012f862ad7faa732b5b0655ce2f=1514443356; historysearch=; Hm_lpvt_3f534012f862ad7faa732b5b0655ce2f=1514508794; YaoTuWang_Passport_Identity=9937796DFDBDE9A6A8AED4D5CF64EA4C22E6DA8F1256977C5DDB6BE83BA2792836A2A6441BE475E64955CB954B8A3C9BB962787AB25BA4E7E92EB98327D6A27934100ADE884D0F28E4D4DC2D60157EFCEA7568AFE2B3E7F059A623B3EE22F4024587087B0E98014BFD4E6AFEBA9D49A55B8B8335492218875C700F2DCBEC637CED603E8A15396800BC68A7A867559AEB744195D1";
                    return;
                }

                string name = CommonFun.GetValue(m.Value, "\">", "</a>");

                if (name.Contains("注射"))
                {
                    return;
                }
                else
                {
                    BaseItemInfo info = new BaseItemInfo();

                    string[] nameArray = name.Split(' ');

                    if (nameArray.Length > 1)
                    {
                        info.Name = nameArray[1];
                    }
                    else
                    {
                        info.Name = nameArray[0];
                    }

                    MatchCollection msFormatAndCreated = CommonFun.GetValues(m.Value, "<div class=\"h1\">", "</div>");

                    info.Format        = msFormatAndCreated[1].Value;
                    info.Created       = msFormatAndCreated[2].Value;
                    info.PlatformPrice = Convert.ToDecimal(priceStr);

                    AddItme(info, "YaoTu/YaoTu" + ticks + ".csv");
                }
            }
        }
Exemple #7
0
        /// <summary>
        /// 自动接单
        /// </summary>
        /// <returns></returns>
        public bool AutoGetOrder(Http.HttpRequest http)
        {
            //获取订单
            string content = GetOrderList(http);

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

            foreach (Match m in ms)
            {
                ProcessOrder(m.Value, http);
            }

            return(true);
        }
Exemple #8
0
        /// <summary>
        /// 获取下架列表
        /// </summary>
        /// <param name="cookie"></param>
        /// <returns></returns>
        public bool GetDownListItem(CookieCollection cookie)
        {
            GetWebPageDate.Http.HttpRequest http = new GetWebPageDate.Http.HttpRequest();

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

            http.Cookie = "acw_tc=AQAAAMj+8lkEeQUA3eT4OlKCFpqJmk95; Qs_lvt_150743=1509785002%2C1510643909; PHPSESSID=0cv28td420q4ii7ult49qm4111; 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; Qs_pv_150743=3457133030228596700%2C2642740307105821700%2C2882295116553261000%2C1172614365052146400%2C979891720064693100; Hm_lvt_ed70f863f631ecaac146592025767ed8=1509785002,1510643909; Hm_lpvt_ed70f863f631ecaac146592025767ed8=1510645265; nTalk_CACHE_DATA={uid:kf_9335_ISME9754_guestTEMP1758-0E75-6A,tid:1510643909116098}; NTKF_T2D_CLIENTID=guestTEMP1758-0E75-6A74-9EB9-8632DF7CEB19; Hm_lvt_3ad2c5e8712b25159b989a93a9927632=1510644101; Hm_lpvt_3ad2c5e8712b25159b989a93a9927632=1510645266; Hm_lvt_7203bc79de07054ef3770e27e8ca9068=1509780503,1509934350,1510060776,1510543588; Hm_lpvt_7203bc79de07054ef3770e27e8ca9068=1510647168";

            string content = http.HttpGet(url);

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

            MatchCollection ms = CommonFun.GetValues(itemStr, "<div class=\"white-box table-box\">", "<div class=\"span2 operationone\">");

            foreach (Match m in ms)
            {
                CommonFun.WriteCSV("TKAdmin/down.csv", GetOneItem(m.Value));
            }

            string pageStr = CommonFun.GetValue(content, "<div><li><span>", "\"><span>末页</span>");

            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(url + "&p=" + i);

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

                ms = CommonFun.GetValues(itemStr, "<div class=\"white-box table-box\">", "<div class=\"span2 operationone\">");

                foreach (Match m in ms)
                {
                    CommonFun.WriteCSV("TKAdmin/down.csv", GetOneItem(m.Value));
                }

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

            return(true);
        }
Exemple #9
0
        /// <summary>
        /// 获取一页的所有物品
        /// </summary>
        /// <param name="itemStr"></param>
        /// <returns></returns>
        public List <BaseItemInfo> GetOnePageItems(string itemStr)
        {
            List <BaseItemInfo> items = new List <BaseItemInfo>();

            itemStr = itemStr.Replace('\n', ' ');
            itemStr = itemStr.Replace('\t', ' ');
            MatchCollection ms = CommonFun.GetValues(itemStr, "<div class=\"tkprolistbox\">", "修改");

            foreach (Match m in ms)
            {
                ItemInfo item = GetOneItem(m.Value);

                items.Add(item);
            }

            return(items);
        }
        public override void ReadAllMenuURL()
        {
            string content = request.HttpGet(url);

            string mainMenuStr = CommonFun.GetValue(content, "nav bb1", "<div class=\"subcat-more\">");

            MatchCollection ms = CommonFun.GetValues(mainMenuStr, "<div class=\"other\">", "</div>");

            foreach (Match m in ms)
            {
                MatchCollection urlMs = CommonFun.GetValues(m.Value, "href=\"", "\"");

                foreach (Match urlM in urlMs)
                {
                    if (!AllMenuUrl.Contains(urlM.Value))
                    {
                        AllMenuUrl.Add(urlM.Value);
                    }
                }
            }

            int startIndex = content.IndexOf("<div class=\"subcat-more\">");

            int endIndex = content.LastIndexOf("<em>&gt;</em></a></div></div>");

            string sumMenuStr = content.Substring(startIndex, endIndex - startIndex);

            MatchCollection ms1 = CommonFun.GetValues(sumMenuStr, "<a href=\"", "\"");

            foreach (Match m in ms1)
            {
                string tempUrl = m.Value;

                if (!AllItemUrl.Contains(tempUrl))
                {
                    if (!tempUrl.Contains("http"))
                    {
                        tempUrl = "http://www.yaofangwang.cn" + tempUrl;
                    }

                    AllMenuUrl.Add(tempUrl);
                }
            }
        }
        public override void ReadAllItemURL()
        {
            try
            {
                string muenUrl = "http://ad.dabai.7lk.com/medication/search";
                foreach (string menuInfo in AllMenuUrl)
                {
                    int page      = 1;
                    int totalPage = 0;
                    do
                    {
                        string content = request.HttpPost(muenUrl, menuInfo + string.Format("&page={0}", page));

                        MatchCollection ms = CommonFun.GetValues(content, "\"id\":", ",");

                        if (totalPage == 0)
                        {
                            string totalPageStr = CommonFun.GetValue(content, "\"totalPages\":", ",");
                            totalPage = Convert.ToInt32(totalPageStr);
                        }

                        foreach (Match m in ms)
                        {
                            if (!AllItemUrl.Contains(m.Value))
                            {
                                AllItemUrl.Add(m.Value);
                            }
                        }
                    } while (++page <= totalPage);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Exemple #12
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);
        }
Exemple #13
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);
                }
            }
        }