Updated scanner to infer when it has reached the end of results.
This commit is contained in:
@@ -4,13 +4,26 @@ namespace JSMR.Infrastructure.Http;
|
||||
|
||||
public class HtmlLoader(IHttpService httpService) : IHtmlLoader
|
||||
{
|
||||
public async Task<HtmlDocument> GetHtmlDocumentAsync(string url, CancellationToken cancellationToken)
|
||||
public async Task<HtmlLoadResult> GetHtmlDocumentAsync(string url, CancellationToken cancellationToken)
|
||||
{
|
||||
string html = await httpService.GetStringAsync(url, cancellationToken);
|
||||
HttpStringResponse response = await httpService.GetAsync(url, cancellationToken);
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
return new HtmlLoadResult
|
||||
{
|
||||
StatusCode = response.StatusCode,
|
||||
Document = null
|
||||
};
|
||||
}
|
||||
|
||||
HtmlDocument document = new();
|
||||
document.LoadHtml(html);
|
||||
document.LoadHtml(response.Content ?? string.Empty);
|
||||
|
||||
return document;
|
||||
return new HtmlLoadResult
|
||||
{
|
||||
StatusCode = response.StatusCode,
|
||||
Document = document
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user