analyzePage function

Future<SnapView> analyzePage(
  1. String htmlStr
)

Implementation

Future<SnapView> analyzePage(String htmlStr) async {
  final document = parse(htmlStr);
  final view = SnapView.emptyView();
  processOgc(document, view);
  processTitle(document, view);
  processSummary(document, view);

  final contentElement = findContentBody(document.body!.children);
  if (contentElement != null) {
    if (view.summary == 'N/A') {
      view.summary = contentElement.text.replaceAll(' ', '').substring(0, 144);
    }
    final img = findImg(contentElement);
    if (img != null) {
      if (view.picture == '') {
        view.picture = img.attributes['src']!;
      }
    }
  }
  processFavicon(document, view);
  return view;
}