Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:beautiful_soup_dart/beautiful_soup.dart';
- import 'package:http/http.dart' as http;
- // written by Developer Eugene
- void main() async {
- // use http to get website content
- var url = Uri.parse('http://dia-calc.ru/cats/?cat=fruits_sub');
- var response = await http.get(url);
- // instanciate BeautifulSoup
- BeautifulSoup beautifulSoupObject = BeautifulSoup(response.body);
- // get every content with the <table>
- var values = beautifulSoupObject.findAll('table').where((element) {
- // get every content with the cellpadding
- var classAttr = element.attributes["cellpadding"];
- // get every content with the classAttr that is not null
- return classAttr != null && classAttr.isNotEmpty;
- });
- for (var element in values) {
- print('Data : ${element.text}');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement