Advertisement
DammyHacks

Untitled

Aug 8th, 2023
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 0.80 KB | Source Code | 0 0
  1. import 'package:beautiful_soup_dart/beautiful_soup.dart';
  2. import 'package:http/http.dart' as http;
  3.  
  4. // written by Developer Eugene
  5. void main() async {
  6.   // use http to get website content
  7.   var url = Uri.parse('http://dia-calc.ru/cats/?cat=fruits_sub');
  8.   var response = await http.get(url);
  9.  
  10.   // instanciate BeautifulSoup
  11.   BeautifulSoup beautifulSoupObject = BeautifulSoup(response.body);
  12.  
  13.   // get every content with the <table>
  14.   var values = beautifulSoupObject.findAll('table').where((element) {
  15.     // get every content with the cellpadding
  16.     var classAttr = element.attributes["cellpadding"];
  17.     // get every content with the classAttr that is  not null
  18.     return classAttr != null && classAttr.isNotEmpty;
  19.   });
  20.   for (var element in values) {
  21.     print('Data : ${element.text}');
  22.   }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement