承接 asymptix/php-html-dom-parser 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

asymptix/php-html-dom-parser

最新稳定版本:v1.5.1

Composer 安装命令:

composer require asymptix/php-html-dom-parser

包简介

Composer adaptation and wrapper for the Simple HTML DOM parser written on PHP5+ let you manipulate HTML in a very easy and fast way. It supports invalid HTML DOM and may find tags in HTML DOM with selectors just like jQuery.

README 文档

README

Composer adaptation and wrapper for the Simple HTML DOM parser written on PHP5+ let you manipulate HTML in a very easy and fast way. It supports invalid HTML DOM and may find tags in HTML DOM with selectors just like jQuery.

Composer installation

To install with Composer simply create this composer.json file in your project root folder and run composer command composer install.

{
	"minimum-stability": "dev",
    "require": {
        "php": ">=5.3.2",
		"asymptix/php-html-dom-parser": "1.5.*"
    }
}

Usage

Here you can find a simple example how to use Parser to parse products from some shop web-site and then parse product details from product pages:

use Asymptix\HtmlDomParser\HtmlDomParser;

require_once('vendor/autoload.php');

$url = "http://www.some-shop.com/";
$html = new HtmlDomParser();
$html->loadUrl($url);
foreach ($html->find("a.product") as $productItem) {
    $productHtml = new HtmlDomParser();
    $productHtml->loadUrl($productItem->href);

    $productDetails = $productHtml->find("div#productDetails", 0);
    $productForm = $productHtml->find("div#productForm", 0);

    $product = new stdClass();

    if (is_object($productForm)) {
        $product->price = $productForm->find("div.price", 0)->plaintext;
    }

    unset($productHtml);
}

Copyright (c) 2012 S.C. Chen, John Schlick, Rus Carroll from the Simple HTML DOM lib developers team.

Copyright (c) 2015 Asymptix.

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 1
  • 开发语言: HTML

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-07-21