webkit2pngでSafariのキャプチャをとる。

ブラウザキャプチャを取る必要が生じたので、探してたら「webkit2png」なるPythonスクリプトがいいみたい。

環境

  • Mac OS 10.5
  • Safari3.2.1
  • Python2.5.1

ダウンロード

githubで公開されてるので、そこからダウンロード。
github-paulhammond / webkit2png

ファイル名が「webkit2png」がPythonの実行ファイル。

実際に使ってみる。

実行は下記の通り。


$ python webkit2png <対象のURL>

ターミナルからの実行例。


$ python webkit2png http://iphonelove.jp

オプション

webkit2pngのオプションは結構ある。縦横幅の指定や出力ファイル名の指定。
詳細は、helpコマンドでみる。


$ python 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
-W WIDTH, --width=WIDTH
initial (and minimum) width of browser (default: 800)
-H HEIGHT, --height=HEIGHT
initial (and minimum) height of browser (default: 600)
--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)
-m, --md5 use md5 hash for filename (like del.icio.us)
-o NAME, --filename=NAME
save images as NAME-full.png,NAME-thumb.png etc
-F, --fullsize only create fullsize screenshot
-T, --thumb only create thumbnail sreenshot
-C, --clipped only create clipped thumbnail screenshot
-d, --datestamp include date in filename
-D DIR, --dir=DIR directory to place images into
--delay=DELAY delay between page load finishing and screenshot
--noimages don't load images

追記

Pythonなので、一通りソースコードに目を通す。