1.1.1 • Published 12 months ago

screenerx v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Screenerx

This nodejs project will create batch screenshots of websites. It uses the awesome puppeteer library which uses a real browser under the hood, e.g. a Chrome or Firefox.

Installation

npm install -g screenerx
# or:
yarn global add screenerx
# or use docker (see below)

Usage

Use arguments

You can call screenerx with arguments:

Examples

# create a screenshot with default settings
screenerx --url https://example.com

# set width and height
screenerx --url https://example.com --width=1200 --height=800

# create a full page screenshot
screenerx --url https://example.com --width=1200 --height=full

# set output path
screenerx --url https://example.com --width=1200 --height=800 --output-path=screenshots/test

# set output file (if not set, the url will be used)
screenerx --url https://example.com --width=1200 --height=800 --output-path=screenshots/test --output-file=example.jpg

# pass an url via stdin (e.g. from a file or echo)
echo "https://example.com" | xargs -I {} ./screenerx.js --url={}
 
# create screenshots in parallel (using gnu-parallel) with 4 threads: 
cat links.txt | parallel --line-buffer -j 4 screenerx --url {}

# docker example (see below for more information)
cat links.txt | parallel --line-buffer -j 4 docker-compose run --rm screenerx --url {}

# specify a link file, default is links.txt (link file is ignored if you specify an url!)
screenerx --file=links.txt

Create a config file

If you like, you can also create a config file. The config file will be used to generate the screenshots.

create a file called screenerconf.json, you can see at screenerconf.json.example for an example. An entry looks basically like this:

{
    "linkFile" : "links.txt",
    "tasks": [
        {
            "name" : "test_landscape",
            "enabled" : true,
            "baseUrl" : "https://www.example.com",
            "linkFile" : "links.txt",
            "browser" : "chrome",
            "width" : "1920",
            "height" : "1080"
        }
    ]
}
propdescription
namename of the task, this will be used in directory name
enabledshould this task run?
baseUrlif you specify a baseUrl, you can use paths only in your urlfile
browserchrome, firefox, etc.. Default is chrome, if you need another browsers, see puppeteer docs how to install these
widthwidth of the screen
heightheight of the screen, can be also "full" to create full size screenshots
linkFileset a different link file for this job

create a text file and put your links into that file. For example links.txt (as specified above in json) The link list can be a normal list with full URLs starting with http://, https:// or you can also only specify the paths. for example /about. The full URL will be generated out of provided baseUrl in screenerx.conf.json and the provided path in links.txt You can specify the linkFile in the root of the json file, but you can also specify / override it in the task itself.

The screenshots will be made in the screenshot folder.

Docker

You can also use this tool in a docker container. Just build the container with docker build -t screenerx . and run it with docker run -it --rm -v $(pwd):/app/screenshots screenerx

or use the docker-compose file:

docker-compose run --rm screenerx

License

MIT

Author

Michael Milawski

1.1.1

12 months ago

1.1.0

12 months ago

1.0.1

1 year ago

1.0.0

1 year ago