Skip to content

Instantly share code, notes, and snippets.

@ohta-rh
Created July 27, 2013 05:44
Show Gist options
  • Save ohta-rh/6093906 to your computer and use it in GitHub Desktop.
Save ohta-rh/6093906 to your computer and use it in GitHub Desktop.
encoding: utf-8
# TODO ①URL解析 ②HTML取得 ③検索部分を抜き出す ④結果をparseする ⑤結果をcsvで表示
require 'open-uri'
require 'csv'
url = ARGV[0] # URLを実行時引数から入力
key_word = (ARGV[1]) # キワードの検索で使用する
html = open(url).read
# ここは使用するかビミョなので一旦コメントアウトする
# html = open(url, "r:binary").read.encode("utf-8", "euc-jp", invalid: :replace, undef: :replace)
key_word = html.scan(key_word)
keyword_times = key_word.count
puts key_word
puts keyword_times
@sakamoto-rh
Copy link

スペースが気になる。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment