WWW::Mechanize付属のmech-dumpが便利な件
Scrapingは余りやらないんですけど、いざやる場合にフォームのパラメタとか調べるのは面倒です。そんな時にWWW-Mechanizeに付属のコマンドのmech-dumpを使うと便利です。
サンプル
例えば、Pathtraqのトップページなら、
$ mech-dump --forms http://pathtraq.com/ GET http://pathtraq.com/analytics url=解析したいサイトのURLを入れてください (text) <NONAME>=解析する (submit) m=hot (radio) [upcoming|*hot|popular|site]
と言う風に出力されます。*1
つまり、
| name | type | value | |||
| url | text | -- | |||
| |
submit | 解析する | |||
| m | radio | hot(/upcoming/popular/site) |
って感じだと分かる訳ですね。
使い方
は--help見れば分かる!
$ mech-dump --help
Usage:
mech-dump [options] [file|url]
Options:
--forms Dump table of forms (default action)
--links Dump table of links
--images Dump table of images
--all Dump all three of the above, in that order
--absolute Show URLs as absolute, even if relative in the page
--help Show this message
The order of the options specified is relevant. Repeated options get
repeated dumps.
*1:Wide Characterのwarningは省略してますw