loadWebPage method

Future<bool> loadWebPage(
  1. String route
)

Loads the webpage into response object.

Implementation

Future<bool> loadWebPage(String route) async {
  if (baseUrl != null && baseUrl != '') {
    final stopwatch = Stopwatch()..start();
    var client = Client();

    try {
      var _response = await client.get(Uri.parse(baseUrl! + route));
      // Calculating Time Elapsed using timer from dart:core.
      timeElaspsed = stopwatch.elapsed.inMilliseconds;
      stopwatch.stop();
      stopwatch.reset();
      // Parses the response body once it's retrieved to be used on the other methods.
      _document = parse(_response.body);
    } catch (e) {
      throw WebScraperException(e.toString());
    }
    return true;
  }
  return false;
}