amir-anisheh/scrapeflow
最新稳定版本:1.3
Composer 安装命令:
composer require amir-anisheh/scrapeflow
包简介
A chainable, SOAP-like HTML parser for Laravel using pure PHP
README 文档
README
ScrapeFlow is a chainable, SOAP-like HTML parser for Laravel using pure PHP.
It allows you to parse HTML from URLs or strings in a fluent, readable way.
Package: amir-anisheh/scrapeflow
Features
- Chainable syntax for fluent HTML parsing
- Select elements by tag, class, id, or attribute
- Get text or HTML of elements
- Pure PHP, no external parsing libraries required
- Ready to use in Laravel with automatic package discovery
Installation
Require the package via Composer:
composer require amir-anisheh/scrapeflow
Or for local development:
"repositories": [ { "type": "path", "url": "../scrapeflow" } ]
Then require it:
composer require amir-anisheh/scrapeflow:@dev
Usage
Basic Example
use AmirAnisheh\ScrapeFlow\HtmlParser; $parser = new HtmlParser(); // Get all titles by class $titles = $parser->url('https://example.com') ->getByClass('title') ->texts(); // Get the first <h1> text $firstH1 = $parser->url('https://example.com') ->getByTag('h1') ->text(); print_r($titles); echo $firstH1;
Chainable Syntax
$parser->url('https://example.com') ->getByClass('container') ->getByTag('h2') ->texts();
Methods
| Method | Description |
|---|---|
url(string $url) |
Load HTML from a URL |
loadHtml(string $html) |
Load HTML from a string |
getByTag(string $tag) |
Select nodes by tag name |
getByClass(string $class) |
Select nodes by class name |
getById(string $id) |
Select nodes by ID |
getByAttribute(string $attr, string $value) |
Select nodes by attribute |
text() |
Get text of the first matched node |
texts() |
Get text of all matched nodes |
html() |
Get HTML of the first matched node |
allHtml() |
Get HTML of all matched nodes |
License
ScrapeFlow is open-sourced software licensed under the MIT license.
Author
Amir Anisheh Email: amirtaja@yahoo.com GitHub: https://github.com/AmirAnisheh
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-06