creode/craft-page-crawler

这将在索引过程中允许爬取页面以获取有用内容。

安装: 39

依赖项: 0

建议者: 0

安全性: 0

星星: 0

关注者: 1

分支: 0

公开问题: 2

类型:craft-plugin

1.1.0 2023-03-03 11:59 UTC

This package is auto-updated.

Last update: 2024-08-30 01:26:39 UTC


README

版本

有关使用Craft CMS的哪个版本使用此包的详细信息,请参阅下表

必需的配置文件

请包含并填写配置文件 "config/page-crawler.php"。以下内容可作为起点。

<?php

use craft\helpers\App;

return [
    /*
     * CSS selectors for elements which should be removed from rendered page markup during a page crawl.
     */
    'elementsToRemove' => [

    ],

    /**
     * If site is behind a htaccess password, you can add the below variables to your .env to determine if we need
     * to bypass it.
     */
    'http-auth-credentials' => [
        'username' => App::env('PAGE_CRAWLER_AUTH_USER'),
        'password' => App::env('PAGE_CRAWLER_AUTH_PASSWORD')
    ],
];

执行爬取

您可以通过调用以下函数使用PHP执行爬取。此函数接受一个相对页面路径,并将返回所有相关页面内容作为文本。

$content = \creode\pagecrawler\Plugin::$plugin->crawlerService->crawl($pagePath);