सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
एक हल्का और दुर्लभ Flutter/Dart पैकेज जो टैग और उनके विशेषताओं को खींचकर HTML सामग्री को निकालता है, और उसे संरचित Dart सूचियों और मानचित्रों में बदलता है। स्थिर वेब पृष्ठों को पार्स करने या HTML स्रोतों से डेटा प्राप्त करने के लिए आदर्श है, जिसमें पूर्ण DOM मैनिपुलेशन की आवश्यकता नहीं होती है। यह मोबाइल, वेब और डेस्कटॉप सहित कई प्लेटफॉर्मों का समर्थन करता है, जिससे यह HTML प्रतिक्रियाओं से संरचित डेटा निकालने की आवश्यकता वाले क्रॉस-प्लेटफॉर्म एप्लिकेशन के लिए लचीला बन जाता है।
उपयोग
स्थिर वेब पृष्ठों से डेटा निकालना
HTML तालिकाओं और सूचियों का विश्लेषण करना
वेब सामग्री से मेटाडेटा निकालना
HTML स्रोतों से स्थानीय डेटा को भरना
सरल वेब क्रॉलर्स बनाना
मुख्य विशेषताएँ
HTML टैग निष्कासन के लिए सरल API
लेखन और सामग्री प्राप्त करने का समर्थन करता है
फ़िल्टर किए गए डेटा को Dart सूचियों और मानचित्र में बदलता है
प्लेटफॉर्म के अनुकूलता
हल्का और एकीकरण में आसान
इनके लिए उपयुक्त
डेटा फीचरिंग ऐप्स बनाने वाले डेवलपर्स
भारी फ्रेमवर्क के बिना HTML पार्सिंग की आवश्यकता वाले प्रोजेक्ट
वेब रैपिंग फीचर्स के प्रोटोटाइपिंग
न्यूनतम सर्वर-साइड प्रोसेसिंग वाले ऐप्स
विचार योग्य बातें
गतिशील JavaScript-आधारित सामग्री के लिए उपयुक्त नहीं
वैध HTML इनपुट की आवश्यकता होती है
गलत HTML को आराम से हैंडल नहीं कर सकता
स्थिर पृष्ठ छानने के लिए सीमित
बाहरी HTML स्रोत विश्वसनीयता पर निर्भर करता है
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
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.