kalimeromk/update-htmldom

为Laravel设计的简单HTML DOM解析器

v1 2022-10-10 06:21 UTC

This package is auto-updated.

Last update: 2024-09-10 10:47:08 UTC


README

基于Simple HTML Dom Parser的Laravel 5到9的Htmldom包

安装

将以下行添加到composer.jsonrequire部分

composer require kalimeromk/update-htmldom

Laravel 5配置

  1. 将服务提供者添加到config/app.php
'providers' => array(
    ...
	'Htmldom\HtmldomServiceProvider',
    ...
  1. config/app.php中添加别名。
'aliases' => array(	
    ...
	'Htmldom' => 'Htmldom\Htmldom',
    ...

使用方法

  1. 使用以下方法
$html = new \Htmldom('http://www.example.com');

// Find all images 
foreach($html->find('img') as $element) 
       {echo $element->src . '<br>';}

// Find all links 
foreach($html->find('a') as $element) 
       {echo $element->href . '<br>';}

查看详细文档http://simplehtmldom.sourceforge.net/manual.htm

s