複数のWebページを効率よくファイル化する方法を教えてください。
なんとか作ったものの冗長なのでページを増やすのが大変な気がします。
ファイルもできれば一つにまとめたいです。
require 'open-uri' url=["http://A.jp" , "http://B.jp" , "http://C.jp"] filename=["filA.html" , "filB.html" , "fileC.html"] url.each do |row| if row == "http://A.jp" File.open(filename[0] , "wb") do |a| text_a = open(url[0] , "r").read a.write text_a end elsif row == "http:/B.jp" File.open(filename[1] , "wb") do |b| text_b = open(url[1] , "r").read b.write text_b end else File.open(filename[2] , "wb") do |c| text_c = open(url[2] , "r").read c.write text_c end end end
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/01 12:48