Package selection guidance compiled from public package information, community data, and project usage.
A lightweight Flutter/Dart package for extracting HTML content by scraping tags and their attributes, converting them into structured Dart lists and maps. Ideal for parsing static web pages or retrieving data from HTML sources without requiring full DOM manipulation. It supports multiple platforms including mobile, web, and desktop, making it versatile for cross-platform applications that need to extract structured data from HTML responses.
Use cases
Extracting data from static web pages
Parsing HTML tables and lists
Scraping metadata from web content
Populating local data from HTML sources
Building simple web crawlers
Key features
Simple API for HTML tag extraction
Supports attribute and text content retrieval
Converts scraped data into Dart Lists and Maps
Cross-platform compatibility
Lightweight and easy to integrate
Suitable for
Developers building data-fetching apps
Projects needing HTML parsing without heavy frameworks
Prototyping web scraping features
Apps requiring minimal server-side processing
Considerations
Not suitable for dynamic JavaScript-rendered content
Requires valid HTML input
May not handle malformed HTML gracefully
Limited to static page scraping
Depends on external HTML source reliability
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
A Simple Web Scraper for Dart & Flutter
A very basic web scraper implementation to scrap html elements from a web page.
Pull requests are most welcome.
Getting Started
In your pubspec.yaml root add:
dependencies:web_scraper:
then,
import'package:web_scraper/web_scraper.dart';
Note that as of version 0.0.6, the project supports not only Flutter projects, but also Dart projects.
Implementation
final webScraper = WebScraper('https://webscraper.io');
if (await webScraper.loadWebPage('/test-sites/e-commerce/allinone')) {
List<Map<String, dynamic>> elements = webScraper.getElement('div.thumbnail > div.caption', ['h4']);
print(elements);
}
Loads the webpage into response object and then parse it into the document object
String route
Future <bool>
loadFromURL
Loads the webpage from provided URL into response object and then parse it into the document object
String page
Future <bool>
loadFromString
Loads the webpage from a String (usually stored by the getPageContent method) into response object and then parse it into the document object. This operation is completely synchronous and exists as a helper method to perform compute() flutter operations and avoid jank
String responseBodyAsString
Future <bool>
getPageContent
Returns webpage's html in string format
Void
String body
getElement
Returns List of elements found at specified address
String address, List <String> attributes
List <Map<String, dynamic>>
getElementTitle
Returns List of element titles found at specified address
String address
List <String>
getElementAttribute
Returns List of elements single attribute found at specified address (if you wish to get multiple attributes at once, please use getElement instead)
String address, List <String> attributes
List <String>
getAllScripts
Returns the list of all data enclosed in script tags of the document
Void
List <String>
getScriptVariables
Returns Map between given variable names and list of their occurence in the script tags
List <String> variableNames
Map <String, dynamic>
Contributing
Please branch from develop to implement bug fix/new feature.
Ensure that code is formatted according to base dart rules & using the latest stable version of dart.
Open a PR with develop as the PR target with a clear description.