예제 #1
0
        static QueueMessageHandler()
        {
            // Global Db api connection antrypoint, using in OnNext handler
            CrawlerApi.ConfigureStaticInstance(Program.Configuration["CrawlerApi:Configuration"]);

            logger = Program.LoggerFactory.CreateLogger <QueueMessageHandler>();
        }
예제 #2
0
        public static async Task Main(string[] args)
        {
            var logger = ConfigLogger();

            if (args.Length >= 1)
            {
                await CrawlerApi.CreateCmdArgs(args, logger);
            }
            else // for non cmd approach - call the crawler from the api you need to execute
            {
                await CrawlerApi.RunBundesarbeitsgerichtAsync(logger);
            }
        }
예제 #3
0
        public async static Task <IApi> GetApi()
        {
            if (apiHelper is null)
            {
                StorageFile storageFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///rule.json"));

                var randomAccessStream = await storageFile.OpenReadAsync();

                Stream stream = randomAccessStream.AsStreamForRead();

                apiHelper = CrawlerApi.GetApi(ApiType.BCY, stream);
            }

            return(apiHelper);
        }
예제 #4
0
        public static async void OnNext(string url)
        {
            try
            {
                Task.Delay(20000).Wait(); // Database is weak

                var pageItems = await HtmlPageParser.GetPageItems(url);

                var pageItemsSerialized = MessagePackSerializer.Serialize(pageItems);
                await CrawlerApi.PostPageInfoAsync(pageItemsSerialized);

                logger.LogInformation($"Page getted: {url}");
            }
            catch (Exception)
            {
                // do nothing
            }
        }
예제 #5
0
 public StoreOrdersService(WiseContext db, CrawlerApi crawlerApi)
 {
     _db         = db;
     _crawlerApi = crawlerApi;
 }