//private string baseUrl = "https://www.b2b-center.ru/";

        public B2B(Tag inpTag, IRequest myReq) : base(myReq)
        {
            if (inpTag.ChildTags.Count != 4)
            {
                Exception e = new Exception("Unknown format! Must be contain 4 child Tags");
                return;
            }

            foreach (Tag item in inpTag.LookForChildTag("a", false, new KeyValuePair <string, string>("class", "search-results-title visited")))
            {
                if (item.Attributes.ContainsKey("href"))
                {
                    LotNameUrl = item.Attributes["href"];
                    if (LotNameUrl.Contains("#btid="))
                    {
                        LotNameUrl = LotNameUrl.Substring(0, LotNameUrl.LastIndexOf("#btid="));
                    }
                    LotNameUrl = baseUrl + LotNameUrl;
                }

                foreach (Tag inItem in item.ChildTags)
                {
                    if (inItem.IsProto & !inItem.IsComment)
                    {
                        LotNameStr = inItem.Value;
                        break;
                    }
                }
            }

            /*
             * LotNameUrl = inpTag.ChildTags[0].ChildTags[0].Attributes["href"];
             * LotNameStr = inpTag.ChildTags[0].ChildTags[0].ChildTags[0].Value;
             */
            if (LotNameStr.Contains("№"))
            {
                TorgType = LotNameStr.Substring(0, LotNameStr.IndexOf("№") - 1);
            }
            LotNumberStr = LotNameStr.Substring(LotNameStr.IndexOf("№") + 1).TrimEnd();

            /*
             * try
             * {
             */
            List <Tag> searchList = inpTag.LookForChildTag("div", false, new KeyValuePair <string, string>("class", "search-results-title-desc"));

            foreach (Tag item in searchList)
            {
                string tmpTorgName    = "";
                string tmpDescription = "";
                foreach (Tag inItem in item.ChildTags)
                {
                    if (inItem.IsProto & !inItem.IsComment)
                    {
                        tmpTorgName += inItem.Value;
                    }
                    else if (inItem.Name == "span")
                    {
                        foreach (Tag itemSp in inItem.LookForChildTag(null))
                        {
                            if (itemSp.IsProto & !itemSp.IsComment)
                            {
                                tmpTorgName += itemSp.Value;
                            }
                        }
                    }
                    else if (inItem.Name == "div")
                    {
                        foreach (Tag itemSp in inItem.LookForChildTag(null))
                        {
                            if (itemSp.IsProto & !itemSp.IsComment)
                            {
                                tmpDescription += itemSp.Value + " ";
                            }
                        }
                    }
                }
                TorgName    = tmpTorgName;
                Description = tmpDescription;
            }

            OrganizerStr = inpTag.ChildTags[1].ChildTags[0].ChildTags[0].Value;
            OrganizerUrl = baseUrl + inpTag.ChildTags[1].ChildTags[0].Attributes["href"];

            DateAcceptStart  = inpTag.ChildTags[2].ChildTags[0].Value;
            DateAcceptFinish = inpTag.ChildTags[3].ChildTags[0].Value;
        }
Exemple #2
0
        ////
        //public Exception LastError { get; private set; }

        public ZakupkiGov(Tag inpTag, IRequest myReq) : base(myReq)
        {
            // registry-entry__header-top__title text-truncate
            List <Tag> workList;
            string     workStr = "";

            // TorgType
            workList = inpTag.LookForChildTag("div", true, new KeyValuePair <string, string>("class", "registry-entry__header-top__title text-truncate"));
            foreach (Tag item in workList)
            {
                bool needBreak = false;
                foreach (Tag itemCh in item.ChildTags)
                {
                    if (itemCh.IsProto & !itemCh.IsComment)
                    {
                        TorgType  = itemCh.Value;
                        needBreak = true;
                        break;
                    }
                }
                if (needBreak)
                {
                    break;
                }
            }

            // TorgNumber
            workList = inpTag.LookForChildTag("div", true, new KeyValuePair <string, string>("class", "registry-entry__header-mid__number"));
            foreach (Tag item in workList)
            {
                bool needBreak = false;
                foreach (Tag itemCh in item.ChildTags)
                {
                    if (itemCh.Name == "a")
                    {
                        if (itemCh.Attributes.ContainsKey("href"))
                        {
                            LotNameUrl = itemCh.Attributes["href"];
                            if (LotNameUrl.Contains("&backUrl="))
                            {
                                LotNameUrl = LotNameUrl.Substring(0, LotNameUrl.LastIndexOf("&backUrl="));
                            }
                        }


                        foreach (Tag itemChCh in itemCh.ChildTags)
                        {
                            if (itemChCh.IsProto & !itemChCh.IsComment)
                            {
                                LotNumberStr = itemChCh.Value;
                                needBreak    = true;
                                break;
                            }
                        }
                        if (needBreak)
                        {
                            break;
                        }
                    }
                }
                if (needBreak)
                {
                    break;
                }
            }

            // Status
            workList = inpTag.LookForChildTag("div", true, new KeyValuePair <string, string>("class", "registry-entry__header-mid__title"));
            foreach (Tag item in workList)
            {
                bool needBreak = false;
                foreach (Tag itemCh in item.ChildTags)
                {
                    if (itemCh.IsProto & !itemCh.IsComment)
                    {
                        Status    = itemCh.Value;
                        needBreak = true;
                        break;
                    }
                }
                if (needBreak)
                {
                    break;
                }
            }

            // LotNameStr
            workList = inpTag.LookForChildTag("div", true, new KeyValuePair <string, string>("class", "registry-entry__body-value"));
            foreach (Tag item in workList)
            {
                string res = "";
                foreach (Tag itemCh in item.LookForChildTag(null))
                {
                    res += itemCh.Value + " ";
                }
                if (res != "")
                {
                    LotNameStr = res.Replace("  ", " ");
                    break;
                }
            }

            // Organizer
            workList = inpTag.LookForChildTag("div", true, new KeyValuePair <string, string>("class", "registry-entry__body-href"));
            foreach (Tag item in workList)
            {
                //bool needBreak = false;
                foreach (Tag itemCh in item.ChildTags)
                {
                    if (itemCh.Name == "a")
                    {
                        if (itemCh.Attributes.ContainsKey("href"))
                        {
                            OrganizerUrl = itemCh.Attributes["href"];
                            if (OrganizerUrl.Contains("&backUrl="))
                            {
                                OrganizerUrl = OrganizerUrl.Substring(0, OrganizerUrl.LastIndexOf("&backUrl="));
                            }
                        }


                        foreach (Tag itemChCh in itemCh.LookForChildTag(null))
                        {
                            if (itemChCh.IsProto & !itemChCh.IsComment)
                            {
                                OrganizerStr += itemChCh.Value + " ";
                                //needBreak = true;
                                //break;
                            }
                        }
                        //if (needBreak)
                        //  break;
                    }
                }
                //if (needBreak)
                //  break;
            }
            OrganizerStr = OrganizerStr.Replace("  ", " ");

            // Price
            workList = inpTag.LookForChildTag("div", true, new KeyValuePair <string, string>("class", "price-block__value"));
            foreach (Tag item in workList)
            {
                bool needBreak = false;
                foreach (Tag itemCh in item.ChildTags)
                {
                    if (itemCh.IsProto & !itemCh.IsComment)
                    {
                        PriceStart = itemCh.Value;
                        needBreak  = true;
                        break;
                    }
                }
                if (needBreak)
                {
                    break;
                }
            }



            // Dates
            workList = inpTag.LookForChildTag("div", true, new KeyValuePair <string, string>("class", "data-block__title"));
            List <Tag> tmpList = inpTag.LookForChildTag("div", true, new KeyValuePair <string, string>("class", "data-block__value"));

            if (workList.Count == tmpList.Count)
            {
                for (int i = 0; i < workList.Count; i++)
                {
                    if (workList[i].ChildTags[0].Value == "Размещено")
                    {
                        DatePost = tmpList[i].ChildTags[0].Value;
                    }
                    else if (workList[i].ChildTags[0].Value == "Обновлено")
                    {
                        DateUpdate = tmpList[i].ChildTags[0].Value;
                    }
                    else if (workList[i].ChildTags[0].Value == "Окончание подачи заявок")
                    {
                        DateFinishAccept = tmpList[i].ChildTags[0].Value;
                    }
                    else
                    {
                        LastError = new Exception("Unexpected DATA in DATE segment!");
                    }
                }
            }

            workStr = LotNameUrl.Replace("https://zakupki.gov.ru/", "").Replace("/epz/order/notice/", "");
            workStr = workStr.Remove(workStr.IndexOf("/"));
            switch (workStr)
            {
            case "ea44":
                Section = "44-ФЗ";
                break;

            case "223":
                Section = "223-ФЗ";
                break;

            case "ea615":
                Section = "ПП РФ 615 (Капитальный ремонт)";
                break;

            case "pgz":
                Section = "94-ФЗ";
                break;

            default:
                Section = "UNKNOWN";
                break;
            }
        }
Exemple #3
0
        //public string baseUrl { get; private set; }
        public LotOnlineSales(Tag inpTag, IRequest myReq) : base(myReq)
        {
            this.baseUrl  = this.baseUrl.Replace("e-auction", "");
            this.baseUrl += "e-auction/";
            this.baseUrl  = this.baseUrl.Replace("//", "/");

            foreach (Tag item in inpTag.LookForChildTag("div", true, new System.Collections.Generic.KeyValuePair <string, string>("id", "new-field-title")))
            {
                foreach (Tag inItem in item.LookForChildTag("a", true, new System.Collections.Generic.KeyValuePair <string, string>("class", "filed filed-title")))
                {
                    if (inItem.Attributes.ContainsKey("href"))
                    {
                        LotNameUrl = inItem.Attributes["href"];
                    }
                    string val = "";
                    foreach (Tag inInItem in item.LookForChildTag(null))
                    {
                        if (!inInItem.IsComment)
                        {
                            val += inInItem.Value;
                        }
                    }
                    LotNameStr = val;
                    if (LotNameUrl != null & LotNameUrl != "" & LotNameStr != null & LotNameStr != "")
                    {
                        break;
                    }
                }
            }
            string tmpStr = "";

            if (LotNameUrl.Contains(";jsessionid="))
            {
                tmpStr = LotNameUrl.Substring(0, LotNameUrl.IndexOf(";jsessionid="));
            }
            if (LotNameUrl.Contains("?parm"))
            {
                LotNameUrl = tmpStr + LotNameUrl.Substring(LotNameUrl.IndexOf("?parm"));
            }
            LotNameUrl = this.baseUrl + LotNameUrl;

            foreach (Tag item in inpTag.LookForChildTag("div", true, new System.Collections.Generic.KeyValuePair <string, string>("id", "new-field-lot")))
            {
                string val = "";
                foreach (Tag inItem in item.LookForChildTag(null))
                {
                    if (!inItem.IsComment)
                    {
                        val += inItem.Value;
                    }
                }
                LotNumberStr = val;
                if (LotNumberStr != null & LotNumberStr != "")
                {
                    break;
                }
            }

            foreach (Tag item in inpTag.LookForChildTag("span", true, new System.Collections.Generic.KeyValuePair <string, string>("class", "price")))
            {
                string val = "";
                foreach (Tag inItem in item.LookForChildTag(null))
                {
                    if (!inItem.IsComment)
                    {
                        val += inItem.Value;
                    }
                }
                PriceStart = val;
                if (PriceStart != null & PriceStart != "")
                {
                    break;
                }
            }

            TableRowMeans = new string[]
            {
                LotNumberStr,
                LotNameStr,
                PriceStart
            };
            TableRowUrls = new string[TableRowMeans.Length];
            TableRowUrls = new string[]
            {
                "",
                LotNameUrl,
                ""
            };
        }
        public ASVorg(Tag inpTag, IRequest myReq) : base(myReq)
        {
            string tmpResult = "";

            if (inpTag.ChildTags.Count > 2)
            {
                List <Tag> OneString = inpTag.LookForChildTag("a");
                foreach (Tag item in OneString)
                {
                    if (item.Attributes.ContainsKey("href"))
                    {
                        LotNameUrl = item.Attributes["href"];
                        if (LotNameUrl.Contains("?sphrase_id"))
                        {
                            LotNameUrl = LotNameUrl.Substring(0, LotNameUrl.LastIndexOf("?sphrase_id"));
                        }
                        LotNameUrl = baseUrl + LotNameUrl;
                        break;
                    }
                }

                OneString = inpTag.ChildTags[0].LookForChildTag(null, true);
                foreach (Tag item in OneString)
                {
                    tmpResult += item.Value;
                }
                LotNameStr = tmpResult;

                tmpResult = "";

                OneString = inpTag.ChildTags[2].LookForChildTag(null, true);
                foreach (Tag item in OneString)
                {
                    tmpResult += item.Value;
                }
                Description = tmpResult;
            }

            string[] indicatorSection = LotNameUrl.Split('/');
            if (indicatorSection.Length > 1)
            {
                switch (indicatorSection[1])
                {
                case "insurance":
                    Section = "Страхование вкладов";
                    break;

                case "liquidation":
                    Section = "Ликвидация банков";
                    break;

                case "agency":
                    Section = "Другое";
                    break;

                default:
                    Section = "НЕИЗВЕСТНО";
                    break;
                }
            }
        }