vakata/downloader
Composer 安装命令:
composer require vakata/downloader
包简介
A PHP class for making a static copy (or indexing) a site
关键字:
README 文档
README
A PHP class for making a static copy (or indexing) a site
Usage
// download a whole site to a folder (new Downloader('https://domain.tld/'))->download(__DIR__ . '/domain.tld/'); // download a part of site to a folder (new Downloader('https://domain.tld/some-path/'))->download(__DIR__ . '/my-backup-copy/'); // if you want to host the static copy out of a subfolder - specify the webroot prefix (new Downloader('https://domain.tld/'))->download(__DIR__ . '/static/', 'static'); // it is possible to specify a custom downloader (new Downloader( 'https://domain.tld/', function (string $url): string { // fetch the $url and return the contents as you see fit } ))->download(__DIR__ . '/static/'); // you can invoke a callback for each item and if that callback returns false - omit writing to disk // this is useful for indexing purposes (new Downloader( 'https://domain.tld/', null, function (string $url, string $data) { // EXAMPLE: save to a database for indexing return false; } ))->download(__DIR__ . '/static/');
Helpers
// there are a couple of methods to help with copying and removing dirs public static function emptyDir(string $dir, bool $delete_self = false): void; public static function copyDir(string $src, string $dst): void;
Example shell script
Used as:
./downloader.php "https://some.tld/"
#!/usr/bin/env php <?php require_once __DIR__ . '/src/Downloader.php'; // the main URL $base = isset($argv[1]) && strpos($argv[1], '://') !== false ? $argv[1] : 'http://localhost/'; // the host $host = explode('/', explode('://', $base, 2)[1], 2)[0]; // where to save the static version to $dest = __DIR__ . '/downloaded/' . basename($host) . '/'; if (!$base) { echo "Missing configuration!\r\n"; die(); } if (is_dir($dest)) { \vakata\downloader\Downloader::emptyDir($dest); } else { mkdir($dest, 0775, true); } \vakata\downloader\Downloader::get($base) // ->add('/search') // ->rewrite(function ($url) { // if (strpos($url, '/upload/') !== false) { // return preg_replace('(upload/(\d+)/.*(\.[a-z0-9]+)$)ui', 'upload/$1$2', $url); // } // return $url; // }) // ->filter(function ($url, $path) { // return strpos($url, 'upload/') === false; // }) ->download($dest);
vakata/downloader 适用场景与选型建议
vakata/downloader 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 790 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 02 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「crawler」 「downloader」 「vakata」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vakata/downloader 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vakata/downloader 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vakata/downloader 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A lightweight, dependency free PHP class that acts as wrapper for Crawlbase API
A random int / string / byte generator
The NzoFileDownloaderBundle is a Symfony Bundle used to Download all types of files from servers and Web applications safely and with ease. You can also read/show the file content in the Web Browser.
A simple PHP IDS based on Expose / PHPIDS rules
PHP powered alternative for youtube-dl
统计信息
- 总下载量: 790
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-02-27