1
私はhttp.get(文字列)でaf画像をダウンロードしようとしています。この文字列はURLです。文字列は認識されず、毎日変更されます。私はその過去をカバーしました。文字列を出力してhttp.getに貼り付けるとうまくいきます。 http.getが変数stringを気にしないのはなぜですか?http.getと文字列
require 'net/http'
Net::HTTP.start("apod.nasa.gov") { |http|
resp = http.get("/apod/")
resp.body.each{|line|
if(line =~ /.jpg/)
line.sub!("<a href=","")
line.gsub!("\"","")
resp = http.get(line)
open("pic.jpg", "wb") { |file|
file.write(resp.body)
}
break;
end
}
}
resp = http.get('/image/1011/cygnusNeb_geissinger1200.jpg')
とサブとそれが動作する...