beautiful_soup_dart 0.0.1 copy "beautiful_soup_dart: ^0.0.1" to clipboard
beautiful_soup_dart: ^0.0.1 copied to clipboard

outdated

Dart native package inspired by Beautiful Soup Python library. Provides easy ways of navigating, searching, and modifying the HTML tree.

Beautiful Soup #

pub package tests

Dart native package inspired by Beautiful Soup Python library. Provides easy ways of navigating, searching, and modifying the HTML tree.

Usage #

A simple usage example:

import 'package:beautiful_soup_dart/beautiful_soup.dart';

/// 1. parse a document String
BeautifulSoup bs = BeautifulSoup(html_doc_string);
// use BeautifulSoup.fragment(html_doc_string) if you parse a part of html

/// 2. navigate quickly to any element
bs.body!.a!; // get String representation of this element, same as outerHtml
bs.find('p', attrs: {'class': 'story'}); // finds first element with html tag "p" and which has "class" attribute with value "story"
bs.findAll('a', attrs: {'class': true}); // finds all elements with html tag "a" and which have defined "class" attribute with whatever value

Bs4Element bs4 = bs.body!.p!; // quickly with tags

/// 3. perform any other actions for the navigated element
bs4.name; // get tag name
bs4.string; // get text
bs4.toString(); // get String representation of this element, same as outerHtml
bs4.innerHtml; // get html elements inside the element
bs4.className; // get class attribute value
bs4['class']; // get class attribute value
bs4['class'] = 'board'; // change class attribute value to 'board'
bs4.children; // get all element's children elements
bs4.replaceWith(otherBs4Element); // replace with other element
... and many more

Check test folder for more examples.

Table of Contents #

The unlinked titles are not yet implemented.

Features and bugs #

Please file feature requests and bugs at the issue tracker or feel free to raise a PR.

108
likes
0
points
2.46k
downloads

Publisher

unverified uploader

Weekly Downloads

Dart native package inspired by Beautiful Soup Python library. Provides easy ways of navigating, searching, and modifying the HTML tree.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

html, source_span

More

Packages that depend on beautiful_soup_dart