Last active
August 29, 2015 14:24
-
-
Save todashuta/a30fa2eae2fffef53fce to your computer and use it in GitHub Desktop.
URLからタイトルを取得する (Macのサービスに入れて右クリックで使う用)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 与えられたURLのタイトル (<title>(.*?)</title>) を取得し、 | |
| # "TITLE" {given-URL} という形式で出力する | |
| require 'open-uri' | |
| require 'nkf' | |
| ARGF.each do |url| | |
| title = NKF.nkf('-w', open(url).read.match(%r{<title>(.*?)</title>}m)[1]) | |
| print %("#{title.strip}" #{url.strip}) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment