示例#1
0
        private async Task GetCategory(IParser parser, IParserSettings settings)
        {
            var loader = new HtmlLoader(settings);
            var source = await loader.GetSourceByMainPage();

            var domParser = new HtmlParser();

            var document = await domParser.ParseDocumentAsync(source);

            var categories = parser.ParseCategory(document);
            var result     = new Dictionary <string, List <Category> >()
            {
                { settings.BurseName, categories }
            };

            OnNewCategory?.Invoke(this, result);
        }
示例#2
0
        private async Task Worker(IParser parser, IParserSettings settings)
        {
            var loader = new HtmlLoader(settings);

            for (int i = settings.StartPoint; i <= settings.EndPoint; i++)
            {
                var source = await loader.GetSourceByPageId(i);

                var domParser = new HtmlParser();

                var document = await domParser.ParseDocumentAsync(source);

                var result = parser.ParseOrder(document);

                await OnNewOrderAsync?.Invoke(result);

                await Task.Delay(10000);
            }
        }