搜索插件、代码仓与 APP 分类

插件详情v0.0.8

chaleno

一个用于通过较少代码行轻松快速地从网站抓取数据的包。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
362
喜欢数
140
Pub 分数
140

安装插件

flutter pub add chaleno

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Chaleno 是一个 Flutter/Dart 包,旨在通过允许开发者使用最少的代码从网站提取数据来简化网络爬虫。它简化了在 Android、iOS、Web、macOS、Windows 和 Linux 等多个平台上获取和解析 HTML 内容的过程。该包注重效率,减少了通常用于 HTTP 请求和 DOM 操作所需的样板代码,非常适合快速数据收集任务。Chaleno 可无缝集成到 Flutter 项目中,并利用 Dart 的异步能力实现快速可靠的爬取操作。

适合场景

  • 从电子商务网站提取产品详细信息
  • 抓取新闻文章或博客帖子
  • 收集公共数据以进行分析
  • 从公共网页自动收集数据

主要特点

  • 网页抓取的最小代码
  • 跨平台支持
  • 内置的 HTML 解析
  • 异步请求处理
  • 轻便且快速
  • 与 Flutter 的轻松集成

适合对象

  • 开发数据聚合工具的开发者
  • 需要频繁进行网络数据提取的项目
  • 快速原型化爬虫
  • 需要实时公共数据的应用

使用建议

  • 确保符合网站的服务条款
  • 限速可能是为了避免被阻止而必要的
  • 不适用于需要复杂JavaScript渲染的网站
  • 可能需要额外的解析逻辑来处理动态内容

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Chaleno

A flutter package for webscraping data from websites.

This package contains a set of high-level functions that make it easy to webscrap websites. It's multi-platform, supports mobile, desktop, and the web.

Usage

Scraping data from websites, this package gives you the power to scrape the web in an easy way.

Instance Chaleno class
var parser = await Chaleno().load('https://example.com');

It returns a Parser which we can use to start webscraping.

You can load HTML file from localhost.

var parser = await Chaleno().load('https://localhost/index');

var parser = await Chaleno().load('https://192.168.1.122/index');
Very simple to use

After instantiating Chaleno class, you can easily retrieve any data using few code lines

Result result = parser.getElementById('id');
print(result.text);

List<Result> results = parser.getElementsByClassName('className');
results.map((item) => print(item.text))

You can return a single result or a list of results and map them. You can find most popular methods and attributes in table below.

Example
final parser = await Chaleno().load('https://example.com');

final title = parser?.getElementById('title').text;
final contents = parser.querySelector('.content-card').text;
final image = parser.getElementsByTagName('img').src;

Importants Methods and propriets

Methods Mean
title Return the page title
getElementById Return a single element searching for ID on the page
getElementsByClassName Return a list of elements according class passed as parameter
getElementsByTagName Return a list of elements according tag passed as parameter
querySelector Return single element passing a list of selector
querySelectorAll Return a list of elements passing a list of selector
text Return text atribute from a tag returned
src Return src atribute from a tag returned
href Return href atribute from a tag returned

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目

暂无相关数据。