从多个IP发出法拉第HTTP请求

时间:2017-02-01 04:01:17

标签: ruby-on-rails ruby http

我正在尝试做这样的事情,以便随机提出不同的IP请求。

   random_ip = ["127.0.0.1", "127.0.0.2"].sample    

    conn = Faraday.new(:url => url) do |faraday|
         faraday.request  :url_encoded             # form-encode POST params
         faraday.response :logger                  # log requests to STDOUT
         faraday.adapter  Faraday.default_adapter  # make requests with Net::HTTP
         faraday.host random_ip
    end
    result = conn.get url

如果它在Linux专用服务器上存在任何差异,那么它就已经存在了。

0 个答案:

没有答案