如何使用https://data.gov.in/resources/all-india-pincode-directory/download等链接下载ruby中的文件

时间:2015-06-29 10:30:44

标签: ruby net-http

我想下载打开红宝石中链接https://data.gov.in/resources/all-india-pincode-directory/download的页面下载的文件

2 个答案:

答案 0 :(得分:0)

我希望这对你有帮助,

puts " download start"
   url = 'https://data.gov.in/resources/all-india-pincode-directory/download '


    open('all_india_pin_code.csv', 'wb') do |file|
      file << open(url).read
    end

    puts " download end"

答案 1 :(得分:0)

有一个名为Open URI的标准库...你试过吗?

require 'open-uri'
file = open("https://data.gov.in/resources/all-india-pincode-directory/download")