示例#1
0
        public override void Select(ICPath cPath)
        {
            string conn = connectionStringBuilder.GetCeonnectionString() + cPath.GetPath().Replace(connectionStringBuilder.GetCeonnectionString(), "");
            string content = getRequest(conn);

            _doc = GetDocument(ref content);

            //SaveToLog(content, "logProduct.txt");
            RemoveOffset(_doc);
        }
示例#2
0
        private bool TryParseNextPage(HtmlDocument doc, out string path)
        {
            path = "";
            //return false;
            string sCurrentPage = HttpUtility.ParseQueryString(_currentPath.GetPath()).Get("page");

            int.TryParse(sCurrentPage, out int tmpCurrentPage);
            _currentPageNum = Math.Max(tmpCurrentPage, _currentPageNum);

            HtmlNode node = doc.DocumentNode.SelectSingleNode(".//nav[@class='paginator-catalog pos-fix']");

            if (node == null)
            {
                return(false);
            }

            HtmlNodeCollection nodes = node.SelectNodes(".//a[@class='blacklink paginator-catalog-l-link']");

            if (nodes == null)
            {
                return(false);
            }

            var l1 = nodes.Where(a => int.TryParse(a.InnerText.Trim(), out int j));

            var pageList = l1.Select(a => new {
                Value = int.Parse(a.InnerText.Trim()),
                Href  = a.Attributes["href"].Value
            }).ToList();

            string nextPageHref = pageList.Where(a => a.Value > _currentPageNum)?.OrderBy(a => a.Value).Select(a => a.Href).FirstOrDefault();

            path = nextPageHref ?? "";
            return(nextPageHref != null);

            if (nextPageHref == null)
            {
                return(false);
            }

            string sNumPage = node.InnerText.Trim();

            node = node.SelectSingleNode(".//a");
            if (node == null)
            {
                return(false);
            }

            path = node.Attributes["href"].Value;

            return(true);
        }
示例#3
0
        public override void Select(ICPath cPath)
        {
            string stringConnect = connectionStringBuilder.GetCeonnectionString();
            string href          = cPath.GetPath();

            href = stringConnect + href.Replace(stringConnect, "");
            string content = getRequest(href);

            HtmlDocument doc = GetDocument(ref content);

            SaveToLog(href + "\n" + content, "logMenu.txt");

            state.SelectMenu(doc);
        }
示例#4
0
        override public void Select(ICPath cPath)
        {
            string conn    = connectionStringBuilder.GetCeonnectionString() + cPath.GetPath().Replace(connectionStringBuilder.GetCeonnectionString(), "");
            string content = getRequest(conn);

            HtmlDocument doc = GetDocument(ref content);

            SaveToLog(content, "logProduct.txt");
            RemoveOffset(doc);
            PrintProduct(doc);

            if (TryParseNextPage(doc, out string href))
            {
                Thread.Sleep(new Random().Next(1000, 3000));
                Select(new CPath(href));
            }
        }
示例#5
0
 public IEnumerator<AdOlxDirty> GetEnumerator()
 {
     _currentPath = new CPath(_initPath.GetPath());
     return Get().GetEnumerator();
 }
示例#6
0
 public IEnumerator <ProductDirty> GetEnumerator()
 {
     _currentPageNum = Constraints.FIRST_PAGE_INDEX;
     _currentPath    = new CPath(_initPath.GetPath());
     return(Get().GetEnumerator());
 }