creode / craft-page-crawler
这将在索引过程中允许爬取页面以获取有用内容。
1.1.0
2023-03-03 11:59 UTC
Requires
- craftcms/cms: ^4.0
- phpquery/phpquery: ^0.0.4
Requires (Dev)
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);