FLUTTER ECOSYSTEM

antonio-nicolau/chaleno

一个 Dart 包,可使用更少的代码行轻松快速地从网站抓取数据。

chaleno 项目封面
Stars
39
Forks
12
最近推送(UTC)
2024年4月3日
项目状态
未归档
António Nicolau GitHub avatar
GITHUB User

António Nicolau ↗

Senior Mobile Developer

Angola
语言C++DartCMakeHTMLCSwiftKotlinObjective-C

技术话题

此仓库发布的插件

使用的依赖

依赖清单 3 项
  • html^0.15.4
  • http^1.2.1
  • flutter_test开发依赖{"sdk":"flutter"}

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

展开 / 收起项目 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