WebShot is an easy-to-use CLI for taking screenshots of webpages. It is based on Rod.
-
go get github.com/gusanmaz/webshot
-
cd $GOPATH/src/github.com/gusanmaz/webshot
-
go install cmd/webshot.go
webshot -url https://www.atlasobscura.com -output atlas.png
webshot -url https://www.atlasobscura.com -width 800 -output atlas2.png
webshot -url https://www.atlasobscura.com -type pdf -output atlas.pdf
Unfortunately for now fo most webpages PDF rendering produces mediocre results
webshot -url https://www.atlasobscura.com -type html -output atlas.html
For now this command only outputs HTML content of the given URL. Other resources referenced in the URL such as images are not captured.
For infinite scroll webpages you need to specify screenshot height and use infinite flag with true value.
webshot -url https://www.flickr.com/search/?text=antalya -height 10000 -type image -output antalya.png -infinite true
You may also modify default values of stepheight and steptime flags. WebShot scrolls infinite page downwards stepheight pixels every steptime milliseconds.
webshot -infinite true -steptime 300 -stepheight 100 -url https://www.flickr.com/search/?text=winter -height 50000 -type image -output winter.png
Güvenç Usanmaz
MIT License