fetchHtml method
Fetches HTML content from a URL
Implementation
Future<String> fetchHtml({
required String url,
Map<String, String>? headers,
}) async {
try {
// Navigate to the URL
await navigateTo(url, headers: headers);
// Wait for the page to load
await waitForDomContentLoaded();
// Get the HTML content
return await getHtml();
} catch (e) {
_log('Error fetching HTML: $e', isError: true);
throw ScrapingException.network(
'Failed to fetch HTML',
originalException: e,
isRetryable: true,
);
}
}