static async Task DollarsTest() { using (Kamaji.Worker.IWorker worker = new WebPageLinksWorker.Worker()) { await worker.SetupEnvironment(); var html = await worker.Run(ConsoleObserver.Instance, "http://www.cursedhardware.com/", null, null); Console.WriteLine(JsonConvert.SerializeObject(html.Result)); Console.ReadKey(); } CancellationTokenSource t = new CancellationTokenSource(); _ = Task.Run(async() => { using (Kamaji.Worker.IWorker worker = new Dollars.Worker()) { await worker.SetupEnvironment(); while (true) { var result = await worker.Run(ConsoleObserver.Instance, null, null, null); IEnumerable <object> list = result.Result as IEnumerable <object>; if (null != list) { (new List <object>(list)).ForEach(i => Console.WriteLine(JsonConvert.SerializeObject(i))); } else { Console.WriteLine(result.Result); } await Task.Delay(5000); if (t.IsCancellationRequested) { break; } } } }); Console.ReadKey(); t.Cancel(); Console.WriteLine("Kapandı"); Console.ReadKey(); }
static async Task SimpleOnes() { using (Kamaji.Worker.IWorker worker = new WebPageLinksWorker.Worker()) { await worker.SetupEnvironment(); var html = await worker.Run(ConsoleObserver.Instance, "http://www.cursedhardware.com/", null, null); Console.WriteLine(html.Result); Console.ReadKey(); } Console.Clear(); using (Kamaji.Worker.IWorker worker = new WebPageScreenshotWorker.Worker()) { await worker.SetupEnvironment(); var html = await worker.Run(ConsoleObserver.Instance, "https://odatv.com/", null, null); Console.WriteLine(html.Result); File.WriteAllBytes("g:\\website_screenshot.png", html.Result as byte[]); Console.ReadKey(); } Console.Clear(); using (WebPageHtmlSourceWorker.Worker worker = new WebPageHtmlSourceWorker.Worker()) { await worker.SetupEnvironment(); // await Task.Delay(300); Stopwatch bench = Stopwatch.StartNew(); var html = await worker.Run(ConsoleObserver.Instance, "https://www.donanimhaber.com/", null, null); bench.Stop(); Console.WriteLine(html.Result); Console.WriteLine("\n\n\n\n\n"); Console.WriteLine(bench.ElapsedMilliseconds); Console.ReadKey(); } }