html_main_element 2.1.0 copy "html_main_element: ^2.1.0" to clipboard
html_main_element: ^2.1.0 copied to clipboard

Detects the main element of a HTML web page, which represents the core article of that page

html_main_element #

Detects the main element of a HTML web page, which represents the core article of that page using a similar algorithm to Readability.

Usage #

A simple usage example:

import 'dart:io';
import 'package:html/parser.dart' as html_parser;

import 'package:html_main_element/html_main_element.dart';

void main() async {
  // Load and parse html document
  final htmlFile = File('test/local/index.html');
  final document = html_parser.parse(await htmlFile.readAsBytes());
  // Genererate score map and get score for every html element
  final scoreMapReadability = readabilityScore(document.documentElement);
  // Get the best scoring html element
  final bestElemReadability = readabilityMainElement(document.documentElement);
  print(bestElemReadability.outerHtml);
}
4
likes
140
pub points
64%
popularity

Publisher

unverified uploader

Detects the main element of a HTML web page, which represents the core article of that page

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-2-Clause (LICENSE)

Dependencies

html

More

Packages that depend on html_main_element