LinkChecker を ubuntu にインストール
Ubuntu上にLinkCheckerを入れる手順のメモ。 前提となる環境はAmazon EC2で用意されている下記のAMI。
pythonのバージョンは2.7が入っている。
$ python -V
Python 2.7.6まずはインストール済のライブラリ等を最新の状態に。
$ sudo apt-get update
Ign http://us-west-1.ec2.archive.ubuntu.com trusty InRelease
Get:1 http://us-west-1.ec2.archive.ubuntu.com trusty-updates InRelease [64.4 kB]
Hit http://us-west-1.ec2.archive.ubuntu.com trusty Release.gpg
(中略)
Get:16 http://security.ubuntu.com trusty-security/universe Translation-en [69.9 kB]
Fetched 10.4 MB in 4s (2,544 kB/s)
Reading package lists... Done次に python-dev をインストール。
$ sudo apt-get install python-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
(中略)
Setting up python2.7-dev (2.7.6-8ubuntu0.2) ...
Setting up python-dev (2.7.5-5ubuntu3) ...
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...次に pip を入れる
$ sudo apt-get install python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
(中略)
Setting up python-pip (1.5.4-1ubuntu3) ...
Setting up python-wheel (0.24.0-1~ubuntu1) ...
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...ここまで準備できたら、LinkChecker をpipコマンドでインストールする。
$ sudo pip install LinkChecker
Downloading/unpacking LinkChecker
Downloading LinkChecker-9.3.tar.gz (719kB): 719kB downloaded
Running setup.py (path:/tmp/pip_build_root/LinkChecker/setup.py) egg_info for package LinkChecker
(中略)
changing mode of /usr/local/bin/linkchecker to 755
Successfully installed LinkChecker
Cleaning up...LinkChecker の実行は以下のようなコマンドで。
#確認したリンク数とリンク切れの数、リンク切れのURLのみコマンドライン上に表示
$ LinkChecker http://www.hogehoge.com/
#確認したリンク数とリンク切れの数、チェックしたすべてのURLをコマンドライン上に表示
$ LinkChecker -v http://www.hogehoge.com/
#確認したリンク数とリンク切れの数、リンク切れのURLをtest.htmlに出力(コマンドラインにも表示)
$ LinkChecker -F html/test.html http://www.hogehoge.com/オプションについてはhelpオプションで確認できる。
$ linkchecker --help
usage: linkchecker [-h] [-f FILENAME] [-t NUMBER] [-V] [--list-plugins]
[--stdin] [-D STRING] [-F TYPE[/ENCODING[/FILENAME]]]
[--no-status] [--no-warnings] [-o TYPE[/ENCODING]] [-q]
[-v] [--cookiefile FILENAME] [--check-extern]
[--ignore-url REGEX] [--no-follow-url REGEX] [-N STRING]
[-p] [-r NUMBER] [--timeout NUMBER] [-u STRING]
[--user-agent STRING]
[url [url ...]]
(後略)Amazon Linux上で同じような手順でインストールしてみたが、LinkChecker のインストールでerror: [Errno 2] No such file or directoryというようなエラーが出てしまって先に進めなかった。