コマンドラインからスクリーンショットを取得するwebkit2png
使ってみた
brewでインストール
brew install webkit2png
ヘルプ。user-agentを指定できたり、サムネイルを取得したり。
わりと色々できそう。
$ webkit2png --help
Usage: webkit2png [options] [http://example.net/ ...]
Examples:
webkit2png http://google.com/ # screengrab google
webkit2png -W 1000 -H 1000 http://google.com/ # bigger screengrab of google
webkit2png -T http://google.com/ # just the thumbnail screengrab
webkit2png -TF http://google.com/ # just thumbnail and fullsize grab
webkit2png -o foo http://google.com/ # save images as "foo-thumb.png" etc
webkit2png - # screengrab urls from stdin
webkit2png -h | less # full documentation
Options:
--version show program's version number and exit
-h, --help show this help message and exit
Browser Window Options:
-W WIDTH, --width=WIDTH
initial (and minimum) width of browser (default: 800)
-H HEIGHT, --height=HEIGHT
initial (and minimum) height of browser (default: 600)
-z ZOOM, --zoom=ZOOM
zoom level of browser, equivalent to "Zoom In" and
"Zoom Out" in "View" menu (default: 1.0)
Output size options:
-F, --fullsize only create fullsize screenshot
-T, --thumb only create thumbnail sreenshot
-C, --clipped only create clipped thumbnail screenshot
--clipwidth=WIDTH width of clipped thumbnail (default: 200)
--clipheight=HEIGHT
height of clipped thumbnail (default: 150)
-s SCALE, --scale=SCALE
scale factor for thumbnails (default: 0.25)
Output filename options:
-D DIR, --dir=DIR directory to place images into
-o NAME, --filename=NAME
save images as NAME-full.png,NAME-thumb.png etc
-m, --md5 use md5 hash for filename (like del.icio.us)
-d, --datestamp include date in filename
Web page functionality:
--delay=DELAY delay between page load finishing and screenshot
--js=JS JavaScript to execute when the window finishes loading
(example: --js='document.bgColor="red";')
--no-images don't load images
--no-js disable JavaScript support
--transparent render output on a transparent background (requires a
web page with a transparent background)
--user-agent=USER_AGENT
set user agent header
このブログのスクリーンショットをとってみた
$ webkit2png http://d.hatena.ne.jp/yuheiomori0718
3つファイルが作成される
dhatenanejpyuheiomori0718-thumb.png dhatenanejpyuheiomori0718-full.png dhatenanejpyuheiomori0718-clipped.png
dhatenanejpyuheiomori0718-clipped.png

fullとthumbは、ブラウザでみたときに1ページにおさまらない分もまとめてキャプチャされてるので、かなり縦に長い。
そういうスクリーンショットを取りたいとき便利かも。
ブラウザからだと取りにくいので。
user-agentを指定してみる
$ webkit2png http://d.hatena.ne.jp/yuheiomori0718 --user-agent="Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5"
ちゃんと効いてるようだ
dhatenanejpyuheiomori0718-full.png

コードはgithubにあってpython製
paulhammond/webkit2png/