v0.1.4
web_scraper
HTML 태그와 그 속성을 스크래핑하여 Dart 및 Flutter용 리스트와 맵으로 변환하는 간단한 웹 스크래퍼입니다.
295좋아요 95130일 다운로드140Pub 점수
AndroidiOSWebmacOSWindowsLinux
웹 페이지에서 HTML 요소를 스크래핑하는 매우 기본적인 웹 스크래퍼 구현
아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
A very basic web scraper implementation to scrap html elements from a web page.
Pull requests are most welcome.
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.
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);
}
Checkout web_scraper_test.dart file to have closer look on all functionalities.
| Method | Description | Arguments | Return Type |
|---|---|---|---|
| loadWebPage | 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> |
Built by developers, for Developers.
Backed up permanently on-chain using Sadaiv CI.