Esempio n. 1
0
 public Task RunAsync(Action <CrawlerResult> result)
 => Task.Run(() => result(CrawlerResult.Ref(
                              _context.HttpClient.Send(_context.Request)
                              .OnError(Fail(result))
                              .OnSuccess(r => TaskResult <Stream> .Wait(r.Content.ReadAsStreamAsync()).ForResult())
                              .OnSuccess(r => _context.HtmlLoader.Load(r.Value))
                              .OnSuccess(r => ToElement(r.Value)))));
Esempio n. 2
0
 private Action <Exception> Fail(Action <CrawlerResult> callback)
 => ex => callback(CrawlerResult.Fail(ex));