定制 hotrush/webshotter 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hotrush/webshotter

Composer 安装命令:

composer require hotrush/webshotter

包简介

Make screnshots of webpages with phantomjs

README 文档

README

Build Status Latest Version Software License Total Downloads

Webshotter

Take website's screenshots with PHP/PhantomJS and save them to PNG, JPG or PDF.

Also you can take a look at simple microservice with lumen and this package - hotrush/Webshotter-microservice.

Changelog

0.1.6 - added waitForImages() and imagesLoadingTimeout

0.1.5 - custom $templatePath fixed, thanks to mizansyed

0.1.3 - added timeout property that allow to limit page load timeout (using onResourceTimeout phantomjs feature). If timeout reached TimeoutException will be thrown.

Installation

composer require hotrush/webshotter

Laravel installation

After installing package via composer add a service provider to your config/app.php

// app/config/app.php

'providers' => [
    ...,
    hotrush\Webshotter\WebshotServiceProvider::class
];

Usage

$webshot = new hotrush\Webshotter\Webshot();
$jpg = $webshot
    ->setUrl('https://github.com')
    ->setWidth(1200)
    ->setHeight(800)
    ->setTimeout(5) // set timeout in seconds, 30 seconds default
    ->setFullPage(true) // set to true to get full page screenshot (width/height will be used for viewport only)
    ->waitForImages() // wait when all images will load
    ->setImagesLoadingTimeout() // images loading timeout, will failt if not loaded
    ->saveToPng('github', $path);

You can use saveToJpg, saveToPng or saveToPdf methods. This methods requires 2 parameters: file name (without extension) and target directory to save file. They all returns full path to saved file

If you want to use you own PhantomJs executable - you can specify path to it via constructor.

new hotrush\Webshotter\Webshot('/path/to/phantomjs');

Example screenshot:

example

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 631
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-01-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固