定制 webignition/html-document-link-finder 二次开发

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

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

webignition/html-document-link-finder

Composer 安装命令:

composer require webignition/html-document-link-finder

包简介

Find anchor URLs in a given HTML document

README 文档

README

Get a collection of absolute urls, with their associated elements, for links in a HTML document.

Usage

Getting a LinkCollection from a WebPage

use webignition\HtmlDocumentLinkUrlFinder\HtmlDocumentLinkUrlFinder;
use webignition\WebResource\WebPage\WebPage;

$webPageUrl = 'http://www.google.co.uk/search?q=Hello+World';
$webPage = WebPage::createFromContent((string) file_get_contents($sourceUrl));

$finder = new HtmlDocumentLinkUrlFinder();
$linkCollection = $finder->getLinkCollection($webPage, $webPageUrl);

Accessing a LinkCollection

use Psr\Http\Message\UriInterface;

// Assuming $linkCollection from previous example

// Iterating
foreach ($linkCollection as $link) {
    $link->getUri();      // UriInterface instance
    $link->getElement();  // \DOMElement instance
}

// Counting
count($linkCollection);

// Get URIs only
$linkCollection->getUris(); // array of UriInterface

// Get unique URIs only
$linkCollection->getUniqueUris(); // array of UriInterface

Filtering a LinkCollection

All LinkCollection::filterBy*() methods return a new LinkCollection instance.

use webignition\Uri\ScopeComparer;

// Filtering
$anchorLinks = $linkCollection->filterByElementName('a');
$elementsWithRelStylesheetAttribute = $linkCollection->filterByAttribute('rel', 'stylesheet');
$linksWithinUrlScope = $linkCollection->filterByUrlScope(
    new ScopeComparer(),
    ['http://example.com/']
);

$linkElementsWithRelStylesheetAttribute = $linkCollection
    ->filterByElementName('link')
    ->filterByAttribute('rel', 'stylesheet');

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2013-08-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固