using System; using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; using AngleSharp; using AngleSharp.Html.Dom; using AngleSharp.Html.Parser; using ExpandedSearchInfo.Sections; namespace ExpandedSearchInfo.Providers { public abstract class BaseHtmlProvider : IProvider { private IBrowsingContext Context { get; } = BrowsingContext.New(); public abstract bool ExtractsUris { get; } public abstract bool Matches(Uri uri); public abstract IEnumerable? ExtractUris(int actorId, string info); public abstract Task ExtractInfo(HttpResponseMessage response); protected async Task DownloadDocument(HttpResponseMessage response) { var html = await response.Content.ReadAsStringAsync(); var parser = this.Context.GetService(); return await parser.ParseDocumentAsync(html); } } }