パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.1.4

web_scraper

HTMLタグとその属性をスクレイピングして、DartおよびFlutter用のリストとマップに変換する簡単なウェブスクレイパー。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
1080
いいね数
295
Pub ポイント
140

パッケージをインストール

flutter pub add web_scraper

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

タグとその属性をスクレイピングしてHTMLコンテンツを抽出し、構造化されたDartのリストやマップに変換する軽量なFlutter/Dartパッケージです。完全なDOM操作を必要とせずに静的Webページを解析したり、HTMLソースからデータを取得するのに最適です。モバイル、Web、デスクトップを含む複数のプラットフォームをサポートしており、HTMLレスポンスから構造化データを抽出する必要があるクロスプラットフォームアプリケーションに非常に柔軟に対応できます。

用途

  • 静的Webページからデータを抽出する
  • HTML テーブルとリストの解析
  • Webコンテンツからメタデータをスクレイピングする
  • HTMLソースからローカルデータを埋め込む
  • シンプルなウェブクローラーの構築

主な機能

  • HTMLタグ抽出用のシンプルなAPI
  • 属性およびテキストコンテンツの取得をサポート
  • スクレイピングされたデータをDartのリストとマップに変換します
  • クロスプラットフォーム互換性
  • 軽量で統合が簡単

適している対象

  • データ取得アプリを開発する開発者
  • 重いフレームワークを使わずにHTMLパースが必要なプロジェクト
  • Webスクレイピング機能のプロトタイピング
  • 最小限のサーバーサイド処理を必要とするアプリ

注意事項

  • 動的なJavaScriptレンダリングコンテンツには適していません
  • 有効なHTML入力が必要です
  • 不正なHTMLをうまく処理できない可能性があります
  • 静的ページのスクレイピングに限定
  • 外部のHTMLソースの信頼性に依存します

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

Pub

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);
    }

Checkout web_scraper_test.dart file to have closer look on all functionalities.

Methods

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>

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.

Built by developers, for Developers.

Backed up permanently on-chain using Sadaiv CI.

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。