Ejemplo n.º 1
0
        public async void Start()
        {
            HtmlLoader htmlLoader = new HtmlLoader(Settings);
            var        html       = await htmlLoader.GetSoursePage();

            HtmlDocument htmlDocument = new HtmlDocument();

            htmlDocument.LoadHtml(html);
            var countPage = htmlDocument.DocumentNode.Descendants("span").Where(count => count.GetAttributeValue("id", "").Equals("total_pages")).FirstOrDefault().InnerText;

            for (int i = parserSettings.Page; i < Convert.ToInt32(countPage); i++)
            {
                if (!IsWorked)
                {
                    OnComplated?.Invoke(this);
                    return;
                }
                html = await htmlLoader.GetSoursePage();

                htmlDocument.LoadHtml(html);
                var items = parser.ParserData(htmlDocument);
                OnNewData?.Invoke(this, items);
            }
            OnComplated?.Invoke(this);
            IsWorked = false;
        }
Ejemplo n.º 2
0
        public async void StartOnce()
        {
            HtmlLoader htmlLoader = new HtmlLoader(Settings);
            var        html       = await htmlLoader.GetSoursePage();

            HtmlDocument htmlDocument = new HtmlDocument();

            htmlDocument.LoadHtml(html);
            var result = parser.ParserData(htmlDocument);

            OnNewData?.Invoke(this, result);
        }