aashan10/scrapeio

此包的最新版本(dev-main)没有提供许可证信息。

用于日常网页抓取的工具。

dev-main 2022-06-01 18:45 UTC

This package is auto-updated.

Last update: 2024-08-29 06:01:57 UTC


README

此库旨在简化网络爬取结果的爬取过程。

安装

composer require aashan10/scrapeio

用法

抓取API由Scrapeio\Scrapper类提供,可以使用以下模式进行使用。

<?php
...
require_once 'vendor/autoload.php';
...

$scrapeio = new \Scrapeio\Scraper('GET', 'https://php.ac.cn/manual/en/function.preg-match.php');
$collection = $scrapeio
    ->setQuery('//div[@id="function.preg-match"]//p[@class="refpurpose"]')
    ->scrape();

echo ($collection->first()->escapeHtmlAndGetData());
echo "<br />";
$collection = $scrapeio->setQuery('//section[@id="usernotes"]//div[@id="allnotes"]//div//strong[@class="user"]//em')->scrape();
echo $collection->count() . ' users contributed to this documentation in php.net!';```