lobotomised/laravel-autocrawler
Composer 安装命令:
composer require lobotomised/laravel-autocrawler
包简介
A tool to crawl your own laravel installation checking your HTTP status codes
关键字:
README 文档
README
Using this package you can check if your application have broken links.
php artisan crawl 200 OK - http://myapp.test/ 200 OK - http://myapp.test/login found on http://myapp.test/ 200 OK - http://myapp.test/register found on http://myapp.test/ 301 301 Moved Permanently - http://myapp.test/homepage found on http://myapp.test/register 404 Not Found - http://myapp.test/brokenlink found on http://myapp.test/register 200 OK - http://myapp.test/features found on http://myapp.test/ Crawl finished Results: Status 200: 4 founds Status 301: 1 found Status 404: 1 found
Installation
This package can be installed via Composer:
composer require --dev lobotomised/laravel-autocrawler
When crawling your site, it will automatically detect the url your application is using. If instead it scan http://localhost, check in your .env you properly configure the APP_URL variable
APP_URL="http://myapp.test"
Usage
Crawl a specific url
By default, the crawler will crawl the URL from your current laravel installation. You can force the url with the --url option:
php artisan crawl --url=http://myapp.test/my-page
Concurrent connection
The crawler run with 10 concurrent connections to speed up the crawling process. You can change that by passing the --concurrency option:
php artisan crawl --concurrency=5
Timeout
The request timeout is by default 30 seconds. Use the --timeout to change this value
php artisan crawl --timeout=10
Ignore robots.txt
By default, the crawler respect the robots.txt. These rules can be ignored with the --ignore-robots option:
php artisan crawl --ignore-robots
External link
When the crawler find an external link, it will check this link. It can be deactivated with the --ignore-external-links option:
php artisan crawl --ignore-external-links
Log non-2xx or non-3xx status code
By default, the crawler will only in your console. You can log all non-2xx or non 3xx status code to a file with the --output option. Result will be store in storage/autocrawler/output.txt
php artisan crawl --output
The output.txt will look like that:
403 Forbidden - http://myapp.test/dashboard found on http://myapp.test/home
404 Not Found - http://myapp.test/brokenlink found on http://myapp.test/register
Fail when non-2xx or non-3xx are found
By default, the command exit codes is 0. You can change it to 1 to indicate that the command has failed with the --fail-on-error
php artisan crawl --fail-on-error
Launch the robot interactively
Eventually, you may configure the crawler interactively by using the --interactive option:
php artisan crawl --interactive
Working with GitHub actions
To execute the crawler you first need to start a web server. You can choose to install apache or nginx. Here is an example using the php build-in webserver
If the crawl found some non-2xx or non-3xx response, the action will fail, and the result will be store as an artifacts of the Action.
steps:
- uses: actions/checkout@v3
- name: Prepare The Environment
run: cp .env.example .env
- name: Install Composer Dependencies
run: composer install
- name: Generate Application Key
run: php artisan key:generate
- name: Install npm Dependencies
run: npm ci
- name: Compile assets
run: npm run build
- name: Start php build-in webserver
run: (php artisan serve &) || /bin/true
- name: Crawl website
run: php artisan crawl --url=http://localhost:8000/ --fail-on-error --output
- name: Upload artifacts
if: failure()
uses: actions/upload-artifact@master
with:
name: Autocrawler
path: ./storage/autocrawler
Documentation
All commands and informations are available with the command:
php artisan crawl --help
Alternatives
This package is heavily inspire by spatie/http-status-check, but instead of being a project dependency, it is a global installation
Testing
First we need to start the included node http server in a separate terminal.
make start
Then to run the tests:
make test
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.
lobotomised/laravel-autocrawler 适用场景与选型建议
lobotomised/laravel-autocrawler 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 43.16k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 08 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「crawler」 「laravel」 「autocrawler」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 lobotomised/laravel-autocrawler 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lobotomised/laravel-autocrawler 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 lobotomised/laravel-autocrawler 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A lightweight, dependency free PHP class that acts as wrapper for Crawlbase API
Sitemap crawler/generator. For the given URL it will return sitemap XML file with URLs and images.
Alfabank REST API integration
Small library for obtaining RSS feed with caching.
simple crawl link and parser it
统计信息
- 总下载量: 43.16k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 28
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-08-16