innmind/crawler

从网页中提取有意义信息的库

安装: 946

依赖项: 4

建议者: 0

安全性: 0

星标: 1

关注者: 3

分支: 0

语言:HTML

6.1.0 2021-02-13 11:35 UTC

This package is auto-updated.

Last update: 2024-09-13 19:36:38 UTC


README

Build Status codecov Type Coverage

此工具允许您从网页中提取大量有用的信息(可能是HTML、图像或其他任何内容)。

安装

composer require innmind/crawler

用法

use function Innmind\Crawler\bootstrap;
use Innmind\OperatingSystem\Factory;
use Innmind\UrlResolver\UrlResolver;
use Innmind\Url\Url;
use Innmind\Http\{
    Message\Request\Request,
    Message\Method\Method,
    ProtocolVersion,
};
use function Innmind\Html\bootstrap as reader;

$os = Factory::build();

$crawl = bootstrap(
    $os->remote()->http(),
    $os->clock(),
    reader(),
    new UrlResolver
);

$resource = $crawl(
    new Request(
        Url::of('https://en.wikipedia.org/wiki/H2g2'),
        new Method('GET'),
        new ProtocolVersion(2, 0),
    ),
);

在这里 $resourceHttpResource 的一个实例。