定制 mitseo/scraper 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mitseo/scraper

Composer 安装命令:

composer require mitseo/scraper

包简介

Parse document with xpath,css selector and regex.

README 文档

README

License: MIT Twitter URL

This library helps you to parse data with different resources :

  • Regex
  • Xpath
  • CSS Selector

Differents outputs are possibles :

  • Match (match():boolean)
  • Count elements (count():int)
  • Extract first element (extractFirst():string)
  • Extract all elements (extractAll():array)

Author : Mitsu

Installation with composer :

Add mitseo/scraper as a require dependency in your composer.json file:

composer require mitseo/scraper

Usage

Parse with Regex

use Mitseo\Scraper\Scraper;

$string = "11111 222 33333 44444";

$regex1 = Scraper::regex("/[0-9]{5}/")->match($string);
$regex2 = Scraper::regex("/([0-9]{5})/")->extractFirst($string);
$regex3 = Scraper::regex("/([0-9]{5})/")->extractAll($string);
$regex4 = Scraper::regex("/[0-9]{5}/")->count($string);

Parse with Xpath

use Mitseo\Scraper\Scraper;

$dom = file_get_contents('https://en.wikipedia.com/');

$xpath1 = Scraper::xpath("//a")->match($dom);
$xpath2 = Scraper::xpath("//a")->extractFirst($dom);
$xpath3 = Scraper::xpath("//a")->extractAll($dom);
$xpath3 = Scraper::xpath("//a")->count($dom);
$xpath4 = Scraper::xpath("//a",["anchor"=>".","href"=>"@href"])->extractTree($dom);

Parse with CSS Selector

use Mitseo\Scraper\Scraper;

$dom = file_get_contents('https://en.wikipedia.com/');

$css1 = Scraper::css("h1#truc")->match($dom);
$css2 = Scraper::css("h1")->extractFirst($dom);
$css3 = Scraper::css("a")->extractAll($dom);
$css4 = Scraper::css("a")->count($dom);

统计信息

  • 总下载量: 165
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-02-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固