GithubHelp home page GithubHelp logo

vbauer / manet Goto Github PK

View Code? Open in Web Editor NEW
577.0 19.0 102.0 1.01 MB

Website screenshot service powered by Node.js, SlimerJS and PhantomJS

License: MIT License

JavaScript 84.06% CSS 1.34% HTML 13.77% Procfile 0.14% Dockerfile 0.70%
nodejs slimerjs phantomjs javascript screenshots gecko webkit heroku

manet's Introduction

Manet Heroku Build Status Dependency Status NPM

There is only one true thing: instantly paint what you see. When you've got it, you've got it. When you haven't, you begin again. All the rest is humbug.

Manet is a REST API server which allows capturing screenshots of websites using various parameters. It is a good way to make sure that your websites are responsive or to make thumbnails.

Manet could use different engines to work: SlimerJS or PhantomJs.

Project was named in honor of Édouard Manet, French painter (1832-1883). He was one of the first 19th-century artists to paint modern life, and a pivotal figure in the transition from Realism to Impressionism.

Main features

  • Ready-To-Use
  • Supporting SlimerJS and PhantomJS
  • Configurable CLI application
  • Flexible REST API
  • File caching
  • Various image formats
  • Sandbox UI

Setup

Preset

Choose and install needed engine (PhantomJS, SlimerJS, or both of them):

SlimerJS:

  • You can download SlimerJS from the official site and install manually.
  • or you can use the power of NPM:
npm install -g slimerjs

Gecko, the rendering engine of Firefox, cannot render web content without a graphical window, but you can launch SlimerJS with xvfb if you are under linux or MacOSx, to have a headless SlimerJS, so it is also necessary to install Xvfb (X virtual framebuffer) for *nix or OS X systems.

For example, you can use apt-get to install xvfb on Ubuntu:

sudo apt-get install xvfb

PhantomJS

  • You can download PhantomJS from the official site and install manually.
  • or you can also use NPM:
npm install -g phantomjs

or (to use second version):

npm install -g phantomjs2

IMPORTANT: PhantomJS is used by default (see default.yaml file).

Installation

After preliminaries operations you can install Manet using NPM:

npm install -g manet

That is all, now you can start and use Manet server. As you can see, it is unnecessary to clone Git repository or something else.

Server launching

Server launching is a simple as possible:

manet

If everything is OK, you should see the following message:

info: Manet server started on port 8891

Server configuration

Manet server uses hierarchical configurations to cover differnet usage use-cases:

  • Command-line parameters
  • Environment variables
  • Built-in configuration YAML file ("config/default.yaml")

Rules of overriding:

  • Each configuration level could be overridden by another level.
  • The most-priority parameters are command-line parameters.
  • The less-priority parameters are stored in build-in configuration file.

CLI parameters

--host
Web server host (default: "0.0.0.0"). Usually, it is unnecessary to change this parameter.
--port
Web server port number. REST API and UI will be available on this port (default: "8891").
--engine
Default engine for screenshot capturing: "phantomjs" or "slimerjs" (default is "phantomjs"). Specific command will be detected by configuration file (default.yaml) using engine parameter and OS platform.
--command
Configuration file "default.yaml" supports specific commands for different platforms (ex: "linux": "xvfb-run -a slimerjs"). Needed command will be detected in runtime by platform/OS. This parameter allows to override command for executing SlimerJS. It allows using full power of SlimerJS command line options to configure proxy, SSL protocol, etc. More information could be found here: http://docs.slimerjs.org/current/configuration.html
IMPORTANT: This parameter overrides "--engine" parameter.
--storage
File storage for cache (default is global temp directory).
--cache
Lifetime for file cache in seconds. Screenshots are cached for 60 minutes by default, so that frequent requests for the same screenshot don't slow the service down. You can configure longer life for cache items or make them ethereal (use zero or negative value).
--cleanupStartup
Clean up FS storage on server startup (default is "false"). It removes all files which were stored previously.
--cleanupRuntime
Clean up FS storage at server runtime (default is "false"). It removes file with captured image after sending on client.
--compress
Additional compression for captured screenshots using Imagemin (default is "false"). File sizes are significantly reduced due to this, but it requires additional processing time. Furthermore, imagemin is an optional dependency. It will be downloaded and installed in runtime during the first request, so it will take an additional time (one time).
--silent
Run Manet server with or without logging information (default is "false").
--level
Setting the level for your logging message. Possible values: debug, info, silly, warn, error (default is "info"). If want to investigate some problem with Manet, use "debug" level: --level=debug
--cors
Enable Cross-Origin Resource Sharing (default is "false").
--ui
Enable or disable sandbox UI (default is "true").
--timeout
Number of milliseconds to wait for the program to complete before sending it "SIGTERM" (default is "60000").
--options:{option}
Default query parameters. See also "Query parameters" for more details. Example: "--options:width 101".
--whitelist
List of URL patterns that are allowed to be processed by Manet (all URLs are permitted by default).
--security:basic:username
Configure user name for Basic authentication. Basic auth will be switched on when "username" and "password" are configured.
--security:basic:password
Configure password for Basic authentication.

Configuration file

Built-in configuration could be found in manet directory. For example, on Ubuntu it is located here: "/usr/local/lib/node_modules/manet/".

Default configuration file ("default.yaml"):

host: 0.0.0.0
port: 8891
cors: false
ui: true

silent: false
level: info

engine: phantomjs
timeout: 60000
compress: false
cache: 3600
cleanupStartup: false
cleanupRuntime: false

commands:
    slimerjs:
        linux: "xvfb-run -a slimerjs"
        freebsd: "xvfb-run -a slimerjs"
        sunos: "xvfb-run -a slimerjs"
        darwin: "slimerjs"
        win32: "slimerjs.bat"
    phantomjs:
        linux: "phantomjs --ignore-ssl-errors=true --web-security=false"
        freebsd: "phantomjs --ignore-ssl-errors=true --web-security=false"
        sunos: "phantomjs --ignore-ssl-errors=true --web-security=false"
        darwin: "phantomjs --ignore-ssl-errors=true --web-security=false"
        win32: "phantomjs --ignore-ssl-errors=true --web-security=false"

whitelist:
    - "*"

security:
    basic:
#        username: admin
#        password: admin

REST API

REST API is available on "/" using:

  • GET method
  • POST method with Content-Type:
    • application/json
    • or application/x-www-form-urlencoded

Few rules:

  • The "url" parameter must be specified.
  • It is possible to send data using query parameters or HTTP Message Body.
  • Query parameters will be used in priority and override others.

Available parameters

url
Website address (URL). This is the only required parameter for the HTTP request. It is unnecessary for the most cases to configure scheme. Example: "github.com".
width
This property allows to change the width of the viewport, e.g., the size of the window where the webpage is displayed (default: `1024`)
height
This property allows to change the height of the viewport. If width is defined and height is not defined, than full page will be captured.
paperFormat
Paper format for PDF export (default is `letter`). Possible values: letter, A2, A3, A4, A5.
paperOrientation
Paper orientation for PDF export (default is `portrait`). Possible values: portrait, landscape.
clipRect
This property defines the rectangular area of the web page to be rasterized. Format: "top,left,width,height", example: "20,20,640,480".
zoom
Zoom factor of the webpage display. Setting a value to this property decreases or increases the size of the web page rendering. A value between 0 and 1 decreases the size of the page, and a value higher than 1 increases its size. 1 means no zoom (normal size). (default: `1`).
quality
The compression quality. A number between 0 and 1 (default value: `1`). Quality parameter doesn't work for PNG file format.
delay
Do a pause during the given amount of time (in milliseconds) after page opening (default: `100`).
format
Indicate the file format for output image (default is `"png"`). Possible values: jpg, jpeg, png, bmp, pdf, ppm, ico.
Format PhantomJS SlimerJS
JPG + +
PNG + +
HTML + +
BMP + -
PDF + -
PPM + -
ICO + -
agent
String to define the "User-Agent" in HTTP requests. By default, it is something like:
  • PhantomJS: Mozilla/5.0 (Macintosh; Intel Mac OS X) AppleWebKit/534.34 (KHTML, like Gecko) PhantomJS/1.9.0 (development) Safari/534.34
  • SlimerJS: Mozilla/5.0 (X11; Linux x86_64; rv:21.0) Gecko/20100101 SlimerJS/0.7
headers
This property specifies additional HTTP request headers that will be sent to the server for every request issued (for pages and resources). Format: "key1=value1;key2=value2;..." Headers names and values get encoded in US-ASCII before being sent. Please note that setting the 'User-Agent' will overwrite the value set via "agent" parameter.
user
User name to give to HTTP Basic authentication.
password
Password to give to HTTP Basic authentication.
js
false to deactivate javascript in web pages (default is `true`).
images
false to deactivate the loading of images (default is `true`).
force
Use the force reloading of web page without using cache (default is `false`).
selector
Wait for the DOM element, that matches the CSS selector, to be available before taking the screenshot.
selectorCrop
Crop page by offset coordinates of selected(by CSS selector) element. (default is `false`). Leave `height` option empty, for this is working correctly.
selectorCropPadding
Add padding to 'selectorCrop'. You can use negative values. (default is 0).
callback
Return an empty response immediately (HTTP 200 OK), then send a POST request to the callback URL when the screenshot is ready (with image in the body).
engine
Override default engine parameter. Possible values: `phantomjs`, `slimerjs`.
cookies
Configure cookies that will be contained in request. HTTP message body is the easiest way for sending cookies to Manet (ex: using JSON format).

Query examples

For a quick test with the command line (using curl), type:

curl http://localhost:8891/?url=github.com > github.png
curl -H "Content-Type: application/json" -d '{"url":"github.com"}' http://localhost:8891/ > github.png
curl -H "Content-Type: application/x-www-form-urlencoded" -d 'url=github.com' http://localhost:8891/ > github.png

or (using wget)

wget http://localhost:8891/?url=github.com -O github.png

Here are some query examples that could be executed by any REST API client:

# Take a screenshot of the github.com.
GET /?url=github.com

# Custom viewport size. Return a 800x600 PNG screenshot of the github.com homepage.
GET /?url=github.com&width=800&height=600

# Clipping Rectangle. Return a screenshot clipped at [top=20, left=30, width=90, height=80]
GET /?url=github.com&clipRect=20%2C30%2C90%2C80

# Zoom rendered page in 2 times.
GET /?url=github.com&zoom=2

# Specify image output format.
GET /?url=github.com&format=jpeg

# Disable JavaScript. Return a screenshot with no JavaScript executed.
GET /?url=github.com&js=false

# Disable images. Return a screenshot without images.
GET /?url=github.com&images=false

# Custom User Agent.
GET /?url=github.com&agent=Mozilla%2F5.0+(X11%3B+Linux+x86_64)+AppleWebKit%2F537.36+(KHTML%2C+like+Gecko)+Chrome%2F34.0.1847.132+Safari%2F537.36

# HTTP Basic Authentication. Return a screenshot of a website requiring basic authentication.
GET /?url=mysite.com&user=john&password=smith

# Screenshot delay. Return a screenshot of the github.com homepage 1 second after it's loaded.
GET /?url=github.com&delay=1000

# Force page reloading. Return a screenshot without using file cache.
GET /?url=github.com&force=true

# Wait for a div element with a class name "header" to be available.
GET /?url=github.com&selector=div.header

# Specify custom HTTP headers.
GET /?url=google.com&headers=User-Agent=Firefox;Accept-Charset=utf-8

# Asynchronous call.
GET /?url=github.com&callback=http://localhost:8891

Sandbox UI

Sandbox UI is available on "/" by direct GET request without "url" query parameter. It is a simple playground to build HTTP requests and try them.

Demo instance is available on Heroku: https://manet.herokuapp.com

You can also use "Deploy to Heroku" button to create your own Manet instance on Heroku without leaving the web browser, and with little configuration.

Deploy

Development

  • To install project dependencies:
npm install
npm run lint
  • To run Mocha unit tests:
# using NPM:
npm test
# using mocha and watcher:
mocha --watch -R spec
  • To run Manet server:
./bin/manet

Alternative clients

Ruby:

Deployment options

Docker

Docker is an open platform to build, ship, and run distributed applications, whether on laptops, data center VMs, or the cloud.

Manet has some already known Dockerfiles:

Heroku

First of all read https://devcenter.heroku.com/articles/deploying-nodejs (section "Deploy your application to Heroku"). You need to create Heroku instance with as described in this documentation.

Procfile file for PhantomJS is already existed in root of the project. This file describes Heroku how to start Manet.

SlimerJS does not work on Heroku, because it has not got a headless mode and it is quite complicated to install xvfb on this platform (but you can try your luck).

Thanks to

Self portrait

One picture more than a thousand words:

License

The MIT License (MIT)

Copyright (c) 2014 Vladislav Bauer (see LICENSE).

manet's People

Contributors

alexstep avatar aubergene avatar bobey avatar cdunlap avatar dependabot[bot] avatar furagu avatar geertvanheusden avatar graingert avatar haykokoryun avatar jiripraus avatar kamronbatman avatar l3o-pold avatar leosprikryl avatar rediris avatar ruemic avatar thomasvnoort avatar vbauer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

manet's Issues

callback not working with php_fastcgi because of missing content-length header

Hi!

I'm trying to implement a php application that will be receiving screenshots generated by manet. I've faced difficulties receiving the screenshots with the callback url.

My logs show:

[Fri Nov 20 01:15:29 2015] [error] [client 127.0.0.1] chunked Transfer-Encoding forbidden: /php5-fcgi/index.php

From my understanding this is because you stream the file directly to the POST request without specifying the content length.

fileStream.pipe(request.post(callbackUrl, (err) => {
if (err) {
sendError(res, 'Error while streaming image file: ' + err.message);
}
onImageFileSent(file, config);
}));

For me this means that i'm not able to use the callback function for my php application.
Can you please add a Content-Length header?

whitelist example please

Hello, I'm trying to configure manet to only allow connections from two IP addresses. I guess the whitelist option is there for that.

I've tried to replace the whitelist option's default value with this:

"whitelist": [
        "127.0.0.1",
        "192.168.0.1"
    ]

When attempting to launch manet The following error is shown on the command line:

$ manet --port 3000

/usr/local/lib/node_modules/manet/node_modules/nconf/lib/nconf/stores/file.js:141
      throw new Error("Error parsing your configuration file: [" + self.file +
            ^
Error: Error parsing your configuration file: [/usr/local/lib/node_modules/manet/src/config/default.json]: Unexpected token /
    at File.loadSync (/usr/local/lib/node_modules/manet/node_modules/nconf/lib/nconf/stores/file.js:141:13)
    at Provider.add (/usr/local/lib/node_modules/manet/node_modules/nconf/lib/nconf/provider.js:137:23)
    at Provider.file (/usr/local/lib/node_modules/manet/node_modules/nconf/lib/nconf/provider.js:63:15)
    at load (/usr/local/lib/node_modules/manet/src/config.js:76:10)
    at Object.read (/usr/local/lib/node_modules/manet/src/config.js:87:30)
    at Object.main (/usr/local/lib/node_modules/manet/src/manet.js:133:23)
    at Object.<anonymous> (/usr/local/lib/node_modules/manet/bin/manet:5:7)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)

While I think the whitelist type is array, this is maybe not the right way to supply IP addresses. Or it could be a bug, but I haven't been able to find the appropriate place in the source code; apparently nconf is being used to validate the configuration file.

Thank you for your help in advance,
Jakob.

[BUG]Write out file will not success and no error throwed (because the tmp file name is too long)

I've found this BUG under Windows 7 64bit, stripping out the raw shell command (manual piece together):

phantomjs "E:\\Program Files (x86)\\nodejs\\node_modules\\manet\\src\\scripts\\screenshot.js" "eyJ1cmwiOiJodHRwOi8vengyNTBsb2NhbC5jb206MzAwMC9tYWdpY3Blbi9hcHAvIy9tYWluL2luZGV4P2l0ZW1MYXlJZD0zJnNuYXBzaG90PTEmX19hPTk2QjcxRDkyOEJFRTM4NkUxMTA2MjFCRUIzN0RGRkYyIiwiZm9ybWF0IjoicG5nIiwid2lkdGgiOjE5MjAsImhlaWdodCI6MTA4MCwic2VsZWN0b3IiOiIjbWFpbi1hcmVhIn0=" "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\yJ1cmwiOiJodHRwOi8vengyNTBsb2NhbC5jb206MzAwMC9tYWdpY3Blbi9hcHAvIy9tYWluL2luZGV4P2l0ZW1MYXlJZD0zJnNuYXBzaG90PTEmX19hPTk2QjcxRDkyOEJFRTM4NkUxMTA2MjFCRUIzN0RGRkYyIiwiZm9ybWF0IjoicG5nIiwid2lkdGgiOjE5MjAsImhlaWdodCI6MTA4MCwic2VsZWN0b3IiOiIjbWFpbi1hcmVhIn0=.png"

this command will run successfully with no extra exceptions, but the temp file will not be writed, so when visit manet, manet will send 404.
searched, linux && windows both have the file name length limiting, so we should keep the temp file name's length, and add a prefix word + a random word + timestamp is well.

at manet/src/capture.js Line 18, i modified:

function outputFile(options, conf, base64) {
    var format = options.format || DEF_FORMAT;
    //zcs=>The base64's length is too long for a file name, so we should fix the length
    var filename = 'manettemp_' + (base64 + '').substr(-20) + '_' + Date.now() + '_' + Math.floor(Math.random() * (999999 - 100000) + 100000);
    //<=zcs
    // return conf.storage + path.sep + base64 + '.' + format; //zcs=old line
    return conf.storage + path.sep + filename + '.' + format;
}

Screenshot of Angularjs app has no async content

Same situation as in closed issue #34

It is an AngularJs app that uses C3js to build SVG charts.
The page has no errors when loading on the browser.
Tried both phantomjs and phantomjs2 (with 2 the delay option doesn't seem to by applied).

In the screenshot I see the basic layout (static assets) of the page, but not the dynamic/async content. Neither the angular rendered parts, nor the generated SVGs are present in the screenshot.

Tried with large delays (20000) even though the page normally loads in low single digit seconds. No luck either.

http status

don't screenshot when the http status is 4xx or 5xx

Ability to take screenshots of logged in pages

Manet is brilliant! One nice feature would be the abiliy to take screenshots of pages that require user authentication. Maybe through PhantomJS (i'm not an expert on it), that could be accomplished by pointing it first to a sign in page if a forbidden 401 status is returned (just a quick example so u can get the idea). For example we could set parameters on the config file so that phantom would be able to log itself

sign_in:
path: /user
user: foo
pass: bar
user_field_matcher : blah
pass_field_matcher: blah

Or even setting cookies (not sure exactly how phantom internals work).

Strange "agent" error with some websites

I'm encountering some weird error when trying to capture certain websites.
As an example: https://www.onpe.tv/
As one can see on the herokuapp demo, it returns the following error

{"error":"Error while sending image file: ENOENT: no such file or directory, stat '/tmp/4379c56e0dfb2442324bfff66228173a77e351e6.png'"}

I'm having the same error on my own machine with phantom 2.1.1 installed

Process Error with slimmerjs

Due to the issue as described here
#19

I enabled slimmerjs instead of phantojs. Now I get a "error: Process errror" for any capture I try to do. Here is the output

curl http://localhost:8891/?url=cnn.com > cnn.png

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0info: Capture site screenshot: cnn.com
**error: Process error:**
100    43  100    43    0     0    148      0 --:--:-- --:--:-- --:--:--   148

Due to the lack of any additional information, I am unable to figure out what is going on. Any ideas?

How to serve manet not at the root of a web domain?

Hi,

We're trying to install Manet for use on one of our servers without having to setup a new subdomain for it nor opening a port to the whole world.

So we were basically just using apache's ReverseProxy to serve manet's port onto a url such as http://www.example.com/manet

It works perfectly for the API part, unfortunately it looks like the code for the web ui is only meant for the app to be served at the baseroot of the domain: the css and js are not found and the open button redirects to root urls

Unable to open file 'src/config/default-styles.css'

attempting to retrieve google.com screenshot of a just reinstalled and started manet:

$ /usr/local/lib/node_modules/manet/bin/manet --port 3000
debug: Initialize FS watchdog: directory: /tmp, timeout: 3600000
info: Manet server started on port 3000
debug: Sending image ("google.com") in response
info: Capture site screenshot: google.com
debug: Options for script: {"url":"http://google.com"}, base64: eyJ1cmwiOiJodHRwOi8vZ29vZ2xlLmNvbSJ9
exec: use child_process.execFile instead
debug: Process output: Script options: {"url":"http://google.com"}
Error: Unable to open file 'src/config/default-styles.css'

error: Process error: Fontconfig warning: ignoring UTF-8: not a valid region tag

Apart from the default-styles.css that can't be found anymore (but is in the same place), and the Fontconfig error that is probably due to a phantomjs issue(?), I can no longer generate snapshots. Not even uncompressed ones.

Any ideas? Thanks!

Getting error "Can not capture site screenshot" on linux, AWS

We're attempting to get Manet running on Amazon Web Services (AWS). We have successfully got things running but we are not getting an image.

Here are some details:

  • Manet is displaying "Can not capture site screenshot".
  • No image is being generated.
  • We have isolated this issue to SlimerJS returning exit code 255.
  • We had the same issue when deploying to a linux environment in house.

Any ideas?

Error while sending file: ENOENT

Hi there,

Manet looks like a great private screen cap service, but I'm having some issues standing it up. Here's my specs:

OSX 10.10.2
Phantomjs 1.9.8 (installed globally via npm)
manet (installed via npm)

But when I run the following:

$ wget http://localhost:8891/?url=github.com -O ~/github.png
--2015-02-23 18:09:58--  http://localhost:8891/?url=github.com
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:8891... failed: Connection refused.
Connecting to localhost|127.0.0.1|:8891... connected.
HTTP request sent, awaiting response... 404 Not Found
2015-02-23 18:10:01 ERROR 404: Not Found.

I get the following:

debug: Execution time: 2 sec
debug: Process finished work: eyJ1cmwiOiJodHRwOi8vdmlzaWEuY2EifQ==
error: Error while sending file: ENOENT, stat '/tmp/eyJ1cmwiOiJodHRwOi8vdmlzaWEuY2EifQ==.png'
debug: Sending image ("github.com") in response
info: Capture site screenshot: github.com
debug: Options for script: {"url":"http://github.com"}, base64: eyJ1cmwiOiJodHRwOi8vZ2l0aHViLmNvbSJ9
debug: Process output: Script options: {"url":"http://github.com"}
TypeError: 'undefined' is not a function (evaluating 'Array.prototype.forEach.call.bind(Array.prototype.forEach)')

  https://assets-cdn.github.com/assets/frameworks-9643b0378c6bcb216adcdaaaa703eed77aa239aaf1c2ae44cadb2fb5099ec172.js:29
  https://assets-cdn.github.com/assets/frameworks-9643b0378c6bcb216adcdaaaa703eed77aa239aaf1c2ae44cadb2fb5099ec172.js:29
ReferenceError: Can't find variable: $

  https://assets-cdn.github.com/assets/github-e481d46e78f12279d9b4fec62c9f7f79d748386efa94431f30b84db4fe996902.js:1
  https://assets-cdn.github.com/assets/github-e481d46e78f12279d9b4fec62c9f7f79d748386efa94431f30b84db4fe996902.js:1
Error: Unable to open file 'src/config/default-styles.css'

debug: Execution time: 2.85 sec
debug: Process finished work: eyJ1cmwiOiJodHRwOi8vZ2l0aHViLmNvbSJ9
error: Error while sending file: ENOENT, stat '/tmp/eyJ1cmwiOiJodHRwOi8vZ2l0aHViLmNvbSJ9.png'`

And I've got a default.json config file that looks like so:

{
    "port": 8891,
    "cors": false,
    "ui": true,

    "silent": false,
    "level": "debug",

    "engine": "phantomjs",
    "options": {},
    "timeout": 9000,
    "compress": false,
    "cache": 0,
    "cleanup": false,

    "commands": {
        "slimerjs": {
            "linux": "xvfb-run -a slimerjs",
            "freebsd": "xvfb-run -a slimerjs",
            "sunos": "xvfb-run -a slimerjs",
            "darwin": "slimerjs",
            "win32": "slimerjs.bat"
        },
        "phantomjs": {
            "linux": "phantomjs",
            "freebsd": "phantomjs",
            "sunos": "phantomjs",
            "darwin": "phantomjs",
            "win32": "phantomjs"
        }
    },

    "whitelist": [
        ".*"
    ]
}

Any idea where I should start looking to debug?

Thanks!

concurrent time does not work

Used in the project, 4 concurrent time does not work, we would like to use, and he saves us a lot of time, but concurrency issues, I do not know whether any improvements
Timeout error results are screenshots actually take screenshots of the address can be quickly opened

Crash on invalid engine value

/usr/local/lib/node_modules/manet/src/capture.js:38
 command = config.command || config.commands[engine][process.platform];
                                                             ^

TypeError: Cannot read property 'linux' of undefined
    at cliCommand (/usr/local/lib/node_modules/manet/src/capture.js:38:62)
    at runCapturingProcess (/usr/local/lib/node_modules/manet/src/capture.js:91:21)
    at retrieveImageFromSite (/usr/local/lib/node_modules/manet/src/capture.js:125:15)
    at /usr/local/lib/node_modules/manet/src/capture.js:137:51
    at FSReqWrap.cb [as oncomplete] (fs.js:216:19)

Black background in jpg

Hello, disabling images in manet makes screenshots with black background in jpg, jpeg. Is there any option to set background color by hand?

Engine selection in the web form

Hi,

It would be great if you could add an option in the web form to select the engine (phantomjs or slimerjs) that you want to be used.

Best regards,

problem with some weird redirected URLs (BBC)

Hello, I'm noticing some weird redirects with URLs from the BBC:

At least from my location, in France, when I attempt to go here http://www.bbc.co.uk/news/business-31599492 I get redirected to http://www.bbc.com/news/business-31599492. However it's not a classic redirect (301 or 302), the web inspector in Chrome doesn't show this redirect, but ends up with the .com page.

Now, how does this concern manet? Well using manet, I don't get a screenshot, but a 404. Not sure that something can be done on manet's level, but I would still be interested?

Thanks,
Jakob.

documentation issue regarding the --cache parameter?

in the readme it says regarding the --cache parameter that one can set it to a 'no-positive value' in order to effectively disable the cache.

when trying to do this, like so:

$ /usr/local/bin/manet --port 3001 --cache -1
error: Cache life time must be a number

it appears that this is not actually possible. For testing it would actually be quite nice to disable the cache.

Why not support an css-selector to be captured?

The feature to support an css-selector not only the width/height option is ducky, sample belows:

page.open(url, function (status) {
    if ('success' != status) return exit('Error: Open url failed!');\
    var clipRect = page.evaluate(function (sel) {
        try {
            return document.querySelector(sel).getBoundingClientRect();
        } catch (e) {
            return null;
        }
    }, config['boxSelector']);

    if (clipRect) {
        page.clipRect = {
            top: clipRect.top,
            left: clipRect.left,
            width: clipRect.width,
            height: clipRect.height
        };
        page.render(outfile, {'format': 'jpeg', 'quality': '70'});
        echo('[SUCCESS]');
    } else {
        echoError('Error: Can\'t find selector: ' + config['boxSelector']);
    }
    exit();
});

Page fails to render AJAX \ Angular content

We have a page that renders correctly in stand-alone PhantomJS (exe). But when run as part of manet, the renderer fails to wait for the page to finish loading data via ajax. The result is that the page is rendered with correct formatting but without data. Even if the timeout is set to 10 seconds. (in reality the page takes about 2 sec or less to load its data).

An example of the page can be found here: http://goo.gl/Y43rb0

How to change user agent?

I have been trying to capture screenshots of mobile webpages by changing the user agent. However, when I provide an iphone user agent as a parameter, I am just getting a blank screen.

Here is the command I am issuing

 http://myserverip:8891/?url=cnn.com&format=jpg&quality=0.5&agent=Mozilla%2F5.0%28iPhone%3BU%3BCPUiPhoneOS4_0likeMacOSX%3Ben-us%29AppleWebKit%2F532.9%28KHTML%2ClikeGecko%29Version%2F4.0.5Mobile%2F8A293Safari%2F6531.22.7

The error logged by the server is as follows:

 debug: Execution time: 1.44 sec
 debug: Process finished work: eyJ1cmwiOiJodHRwOi8vd2lja2VkZmlyZS5jb20iLCJhZ2VudC                                   I6Ik1vemlsbGEvNS4wKGlQaG9uZTtVO0NQVWlQaG9uZU9TNF8wbGlrZU1hY09TWDtlbi11cylBcHBsZV                                   dlYktpdC81MzIuOShLSFRNTCxsaWtlR2Vja28pVmVyc2lvbi80LjAuNU1vYmlsZS84QTI5M1NhZmFyaS                                82NTMxLjIyLjciLCJmb3JtYXQiOiJqcGciLCJxdWFsaXR5IjowLjV9
 error: Error while sending file: ENAMETOOLONG, stat '/tmp/eyJ1cmwiOiJodHRwOi8vd2                                lja2VkZmlyZS5jb20iLCJhZ2VudCI6Ik1vemlsbGEvNS4wKGlQaG9uZTtVO0NQVWlQaG9uZU9TNF8wbG                                lrZU1hY09TWDtlbi11cylBcHBsZVdlYktpdC81MzIuOShLSFRNTCxsaWtlR2Vja28pVmVyc2lvbi80Lj                                AuNU1vYmlsZS84QTI5M1NhZmFyaS82NTMxLjIyLjciLCJmb3JtYXQiOiJqcGciLCJxdWFsaXR5IjowLj                                V9.jpg'

The error disappears when I don't use an agent. BTW, I am using slimerjs engine to render the pages.

heroku deployment issue with slimerjs

I have been successfully able to deploy the app running phantomjs on heroku. However, when I change to slimerjs (in Procfile), everything proceeds normally (no errors during deployment). But the app is not fetching any data. It always gives following error.

 {"error":"Can not capture site screenshot"}

Am I suppose to change anything else?

Whitelist urls / domains

It would be great to be able to configure which domains or endpoints the service would be able to render.
This is helpful so that other sites cannot serve thumbnails from your site.

PNG compression

Thanks for the great library (I migrated from https://github.com/fzaninotto/screenshot-as-a-service).

Is there a way to modify the PNG compression? Or perhaps the color palette?

When I take a screenshot of a black and white document with pure text on a white background, the resulting PNG file is still well over 1MB.

When I use the JPEG or PDF compression, the file is much smaller.

Any tips?

Support for webgl

Hi there,

Thank you for creating manet. When running the following command:
curl http://localhost:8891/?url=http://moveme.io/app.html#bG9hZCBhc3NldCB0aW55 > moveme.png

I get the following error:
I'm getting an image which states that that the browser (gecko?) doesn't support webgl. Not sure if this actually due to something manet related. Maybe this is slimerJS related? Then again, as far as I understand slimerJS gets used by default by manet and slimerJS supports webgl. Maybe it's missing a flag/argument somewhere or maybe I'm doing something wrong. Any help welcome.

Thanks,

Manu

Multiple --options params ???

When I change Procfile to:
web: npm install -g phantomjs && ./bin/manet --port $PORT --options:format png --options:force true

The force is still at default value force=false, how can I set default value to force=true with CLI parameter?

size of screenshots is huge!

[This might be a duplicate of #14]

Me again. I've noticed that screenshots taken with manet are huge, size-wise. For example, the Google homepage, as a screenshot is about 3 MB in size (see screenshot of the screenshot below). Others go easily to 8 MB and beyond. manet was started like this:

forever start -a -l ~/manet.log -o ~/manet.out -e ~/manet.err /usr/local/bin/manet --port 3000 --engine phantomjs

In comparison, screenshot-as-a-service (from here: https://github.com/fzaninotto/screenshot-as-a-service) produces screenshots of only a couple of hundred kilobytes, and their quality are comparable.

Any idea what I could change to decrease the size? I'm using the option quality=0 but that hasn't had any impact on size. I've also tried changing the engines (phantomjs vs slimerjs) but I don't see a difference either.

Thanks for your help in advance.

screen shot 2015-02-20 at 10 07 15

how to see settings of manet instance

When I have manet running, is there a way to see what the different configuration options are that are being used (in the sandbox maybe)? I'm thinking of the rasterisation engine (slimerjs or phantomjs), the compression, which config JSON file being used etc.

Or an additional option that shows them without starting manet, --debug or --verbose ... just making this up.

I'm asking because even though I'm currently running 0.3.4 my screenshots are seemingly uncompressed (Google homepage at 3MB instead of 21KB), and I'd like to look into this more before filing a bug. Also, the --compress true doesn't seem to have any effect anymore.

Where is the JSON file located that's being used? And can I use another one located elsewhere that overloads the default values?

Thanks!

documentation for running Manet as a service on Ubuntu

Sorry to have to ask this noob question, but I am having a hard time getting Manet to run in the background, as a service at boot. Since this is already in bin, I am confused at which to use: pm2 or a rc.d-like approach. halp?

How manet can handle redirect URL

Hi,

Inside a manet im giving a url which is basically redirect to another url. So i need pdf of second url. As of now i am geeting pdf of first url. What should i do???

Error: EISDIR: illegal operation on a directory, unlink

2016-02-09T10:18:54.087Z - info: Initialize FS watchdog: directory: /tmp, timeout: 1000
2016-02-09T10:18:54.096Z - info: Manet server started on 0.0.0.0:8891
2016-02-09T10:18:55.090Z - error: Error: EISDIR: illegal operation on a directory, unlink '/tmp/npm-12-24411478'
at Error (native)

Heroku installation instructions?

Would you mind sharing what's needed to get this running on Heroku? I'm not too familiar with Node.js, so any help is appreciated.

ddos protected websites

Hi,
I'm trying to get in prod manet for a listing website and i'm having trouble on ddos protected websites (cloudflare and other cookie based protection techniques).
is there any handler that reads the initial cookie and then returns it back to the request in order to bypass the protection?

thanks

Api key or other security mechanism?

Is there an easy way to secure the webservice with an api key or username/password?
I feel very uncomfortable by exposing the control over a fully functional webbrowser to anyone who is smart enough to guess the port number...

Resize images

Hello, I have been using manet, so far is works pretty good, I would like to know if it would be hard to implement image resizing, for example I would like to get thumbnails for desktop screenshots, I would like to implement this myself however I don't know exactly where should I place the code.

https://www.npmjs.com/package/resize

this seems like a good library for this.

function minimizeImage(src, dest, cb) {
    squirrel(
        IMIN_MODULES, IMIN_OPTIONS,
        (err, Imagemin) => {
            const safeCb = (err) => {
                if (err) {
                    logger.error(err);
                }
                cb();
            };

            if (err) {
                safeCb(err);
            } else {
                const imin = new Imagemin()
                    .src(src)
                    .dest(dest)
                    .use(Imagemin.jpegtran({progressive: true}))
                    .use(Imagemin.optipng({optimizationLevel: 3}))
                    .use(Imagemin.gifsicle({interlaced: true}))
                    .use(Imagemin.svgo());

                imin.run(safeCb);
            }
        }
    );
}

I am guessing I should make a function like this one ?

and then add it here

function runCapturingProcess(options, config, outputFile, base64, onFinish) {
    const scriptFile = utils.filePath(SCRIPT_FILE),
          command = cliCommand(config).split(/[ ]+/),
          cmd = _.union(command, [scriptFile, base64, outputFile]),
          opts = {
              timeout: config.timeout
          };

    logger.debug(
        'Options for script: %s, base64: %s, command: %s',
        JSON.stringify(options), base64, JSON.stringify(cmd)
    );

    utils.execProcess(cmd, opts, (error) => {
        if (config.compress) {
            minimizeImage(outputFile, config.storage, () => onFinish(error));
            //resize here ?
        } else {
            onFinish(error);
        }
    });
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.