tabimoba.net

とあるエンジニアの雑記帳

Lynxでページ内のハイパーリンクの全リンクを取得する方法

LynxLinuxやBSDなどUnix系OSで動作する定番のテキストブラウザです。

lynxにURLとあわせて「-dump」オプションを加えると、そのページ内の全ハイパーリンク(全URL)を一覧で表示することができます。

$ lynx -dump http://www.google.com/

ファイルに結果を出力する場合は

$ lynx -dump http://www.google.com/ > hoge.txt

とします。

出力例

$ lynx -dump  http://www.google.com/
   検索 [1]画像 [2]地図 [3]Play [4]YouTube [5]ニュース [6]Gmail [7]ドライブ [8]もっと見る ≫
   [9]ウェブ履歴 | [10]設定 | [11]ログイン

   Google
          日本

     _______________________________________________________
   Google 検索  I'm Feeling Lucky    [12]検索オプション
      [13]言語ツール

   Google.co.jp offered in: [14]English

   [15]広告掲載     [16]ビジネス ソリューション     [17]+Google     [18]Google について
   [19]Google.com

               c 2013 - [20]プライバシーと利用規約

参照

   1. http://www.google.co.jp/imghp?hl=ja&tab=wi
   2. http://maps.google.co.jp/maps?hl=ja&tab=wl
   3. https://play.google.com/?hl=ja&tab=w8
   4. http://www.youtube.com/?gl=JP&tab=w1
   5. http://news.google.co.jp/nwshp?hl=ja&tab=wn
   6. https://mail.google.com/mail/?tab=wm
   7. https://drive.google.com/?tab=wo
   8. http://www.google.co.jp/intl/ja/options/
   9. http://www.google.co.jp/history/optout?hl=ja
  10. http://www.google.co.jp/preferences?hl=ja
  11. https://accounts.google.com/ServiceLogin?hl=ja&continue=http://www.google.co.jp/
  12. http://www.google.co.jp/advanced_search?hl=ja&authuser=0
  13. http://www.google.co.jp/language_tools?hl=ja&authuser=0
  14. http://www.google.co.jp/setprefs?sig=0_wA4_e3nycB6Zq9hXTLdxjxYKMFs%3D&hl=en&source=homepage
  15. http://www.google.co.jp/intl/ja/ads/
  16. http://www.google.co.jp/intl/ja/services/
  17. https://plus.google.com/115899767381375908215
  18. http://www.google.co.jp/intl/ja/about.html
  19. http://www.google.co.jp/setprefdomain?prefdom=US&sig=0_4kswb-lulG3LrnkmsaIi_TMlQvw%3D
  20. http://www.google.co.jp/intl/ja/policies/