screenit
A Golang library and CLI tool for capturing web page screenshots with configurable options.
Installation
Go
go install github.com/root4loot/screenit/cmd/screenit@latest
Docker
git clone https://github.com/root4loot/screenit.git && cd screenit
docker build -t screenit .
docker run -it screenit -h
Usage
Usage: ./screenit [options] (-u <url> | -i <urls.txt>)
INPUT:
-u, --url target URL
-i, --infile file containing URLs
CONFIGURATIONS:
-c, --concurrency number of concurrent requests (Default: 10)
-t, --timeout screenshot timeout (Default: 15 seconds)
-ua, --user-agent set user agent (Default: Chrome Headless)
-su, --save-unique save unique screenshots only (Default: false)
-wb, --wait-for-body wait for page body to load (Default: true)
-ice, --ignore-cert-err ignore certificate errors (Default: true)
-dh, --disable-http2 disable HTTP2 (Default: true)
-fr, --follow-redirects follow redirects (Default: true)
-cw, --capture-width screenshot pixel width (Default: 1024)
-ch, --capture-height screenshot pixel height (Default: 768)
OUTPUT:
-o, --outfolder save images to given folder (Default: ./screenshots)
-s, --silence silence output
-v, --verbose verbose output
Example running
Running against list of URL's and waiting for HTML BODY to fully render before capturing screenshot:
✗ screenit -i urls.txt --wait-for-body
[SCREENIT] (INFO) Screenshot http://example.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot https://example.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot http://hackerone.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot https://hackerone.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot http://google.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot http://bugcrowd.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot https://bugcrowd.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot https://google.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot https://facebook.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot http://facebook.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot http://yahoo.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot https://yahoo.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot http://github.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot https://github.com saved to ./screenshots
[SCREENIT] (WARNING) Timeout exceeded for http://tesla.com
[SCREENIT] (WARNING) Timeout exceeded for https://tesla.com
URL's may also be piped / streamed to STDIN:
✗ screenit cat urls.txt | go run cmd/screenit/* -v
[SCREENIT] (INFO) Screenshot http://example.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot https://example.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot http://example.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot https://example.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot http://hackerone.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot https://hackerone.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot http://hackerone.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot https://hackerone.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot https://google.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot http://google.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot http://bugcrowd.com saved to ./screenshots
[SCREENIT] (INFO) Screenshot https://bugcrowd.com saved to ./screenshots
As lib
go get github.com/root4loot/screenit
package main
import (
"fmt"
"github.com/root4loot/screenit"
)
func main() {
// List of URLs to capture
urls := []string{
"https://example.com",
"https://hackerone.com",
"https://bugcrowd.com",
"https://google.com",
"https://facebook.com",
"https://yahoo.com",
"https://tesla.com",
"https://github.com",
}
// Set options
options := screenit.Options{
Concurrency: 10,
Timeout: 15,
SaveScreenshots: true,
WaitForPageBody: false,
FollowRedirects: true,
DisableHTTP2: true,
IgnoreCertificateErrors: true,
Verbose: false,
Silence: true,
}
// Create a screenit runner with options
runner := screenit.NewRunnerWithOptions(options)
// Create a channel to receive results
results := make(chan screenit.Result)
// Start capturing URLs using multiple goroutines
go runner.MultipleStream(results, urls...)
// Process the results as they come in
for result := range results {
fmt.Println(result.URL, result.Error, len(result.Image))
}
}
For more, see examples
License
See LICENSE
Contributing
See CONTRIBUTING.md