private void parsePages() { // Inform the world of us doReport(MessageKind.Info, "Parsing the page: " + Constants.SITE_URL); // Create the frontpage parser FrontPageParser frontParser = new FrontPageParser(Constants.SITE_URL); // Let the parser inform us frontParser.onReport += (msgKind, msgText) => { doReport(msgKind, msgText); }; // React on downloading completed frontParser.onDownloaded += (sender, data, isOk, error) => { if (!isOk) { doReport(MessageKind.Error, "Downloading failed: " + error); return; } doReport(MessageKind.Info, "Downloading succeeded"); }; // React on index page parsing completed frontParser.onParsed += async(sender, headers, isOk, error) => { if (!isOk) { doReport(MessageKind.Error, "Index parsing failed: " + error); return; } // Announce the results of index parsing doReport(MessageKind.Info, "Index page has been parsed successfully"); doReport(MessageKind.Info, String.Format("{0} articles found:", headers.Count())); // Print headers printArticlesList(headers); // Proceed to pages parsing var data = parseArticles(headers); // Export and then red the data bool mongoRes = await mongoData(data, headers); if (!mongoRes) { _isDone = true; return; } _isDone = true; }; // Initiate the index parsing frontParser.beginParse(); }
public V1Controller(ILogger <V1Controller> logger, ChattyProvider chattyProvider, SearchParser searchParser, FrontPageParser frontPageParser, MessageParser messageParser) { this._logger = logger; _chattyProvider = chattyProvider; _searchParser = searchParser; _frontPageParser = frontPageParser; _messageParser = messageParser; }