parseExamplePageData function

ExampleResults parseExamplePageData(
  1. String pageHtml,
  2. String phrase
)

Parses a jisho example sentence search page to an object

Implementation

ExampleResults parseExamplePageData(String pageHtml, String phrase) {
  final document = parse(pageHtml);
  final divs = document.querySelectorAll('.sentence_content');

  final results = divs.map(_parseExampleDiv).toList();

  return ExampleResults(
      query: phrase,
      found: results.isNotEmpty,
      results: results,
      uri: uriForExampleSearch(phrase).toString());
}