PHP Wraith 是一个使用 Selenium 的截图比较工具 - 使用 PHP 编写。

1.0.0 2021-02-04 16:17 UTC

This package is auto-updated.

Last update: 2024-08-29 05:30:43 UTC


README

Packagist Release Packagist Downloads GitHub License

PHP Wraith

PHP Wraith 是一个使用 Selenium 的网站爬虫和截图比较工具 - 使用 PHP 编写。

此工具基于bbc/wraith的思路。

安装

先决条件

系统要求

安装源

要么 使用 Composer 安装此包

composer require different-technology/wraith-php

要么 从 GitHub 克隆代码

git clone git@github.com:different-technology/wraith-php.git
cd wraith-php
composer install

Chromedriver

下载与您的 Chrome 版本兼容的 chromedriver: https://chromedriver.chromium.org/downloads

将 chromedriver 放置于此处(可选): bin/chromedriver

配置

/configs 中的自己的 YAML 配置文件中配置您的网站。

参见/configs/example.yml中的示例

启动

运行 chromedriver(可选)

在执行命令时,chromedriver 必须在配置的端口(默认: 4444)上运行。

启动 chromedriver

bin/chromedriver --port=4444

如果没有 chromedriver,您也可以使用自动启动选项来自动启动它。

截图

使用您的配置名称(不带 .yml 扩展名的文件名)调用 screenshot 命令。

php app.php screenshot {{your-config-name}} {{threads-count(optional)}}

结果存储在目录 /data/screenshots/{{your-config-name}}/{{current-date-time}} 中。

您可以将最后一个目录名称从 {{current-date-time}} 重命名为有意义的名称。

示例

# Take screenshots
php app.php screenshot example 3
# Rename screenshots to "before-update"
mv data/screenshots/example/2021-02-04_10-10-55 data/screenshots/example/before-update

比较

使用您的配置名称(不带 .yml 扩展名的文件名)调用 compare 命令。

提供要比较的两个目录名称。

php app.php compare {{your-config-name}} {{directory1}} {{directory2}}

示例

php app.php compare example 2021-02-04_00-05-35 2021-02-04_00-38-37

连接

您可以连接到正在运行的任务,以在单个任务上使用线程进行工作(任务必须支持作业)。

只需在目录 /data/jobs/ 中查找作业-id。

php app.php join {{your-config-name}} {{job-id}}

示例

php app.php join example d6f7f694f8563362e17ae6ab64d1578f

列出命令

您可以使用 symfony 的 help 命令列出所有可用命令

php app.php list

显示结果

在浏览器中打开此文件以查看结果: public/index.html