Files
jsmr/JSMR.Infrastructure/Http/HtmlLoader.cs
Brian Bicknell 62c2efab01
All checks were successful
ci / build-test (push) Successful in 2m18s
ci / publish-image (push) Has been skipped
Updated scanner to infer when it has reached the end of results.
2026-03-07 01:26:04 -05:00

29 lines
789 B
C#

using HtmlAgilityPack;
namespace JSMR.Infrastructure.Http;
public class HtmlLoader(IHttpService httpService) : IHtmlLoader
{
public async Task<HtmlLoadResult> GetHtmlDocumentAsync(string url, CancellationToken cancellationToken)
{
HttpStringResponse response = await httpService.GetAsync(url, cancellationToken);
if (!response.IsSuccessStatusCode)
{
return new HtmlLoadResult
{
StatusCode = response.StatusCode,
Document = null
};
}
HtmlDocument document = new();
document.LoadHtml(response.Content ?? string.Empty);
return new HtmlLoadResult
{
StatusCode = response.StatusCode,
Document = document
};
}
}