我刚刚安装了ruby,并一直遵循Ruby教程。我开始了本教程:https://www.distilled.net/resources/web-scraping-with-ruby-and-nokogiri-for-beginners/
我在哪里得到SSL错误,所以我在http://guides.rubygems.org/ssl-certificate-update/上使用了指南
不过,我的问题是,当我请求这个版本时,我的版本是ruby2.6.7,但是当我运行这个代码时,我的版本是ruby2.6.7:
require 'Nokogiri'
require 'HTTParty'
require 'JSON'
require 'Pry'
require 'csv'
page = HTTParty.get('https://google.com/')
Pry.start(binding)我知道这个错误
C:\Ruby22\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) C:/Users/Tom/RubymineProjects/projectone/projectone.rb
C:/Ruby22/lib/ruby/2.2.0/net/http.rb:923:in `connect': SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (OpenSSL::SSL::SSLError)
from C:/Ruby22/lib/ruby/2.2.0/net/http.rb:923:in `block in connect'
from C:/Ruby22/lib/ruby/2.2.0/timeout.rb:73:in `timeout'
from C:/Ruby22/lib/ruby/2.2.0/net/http.rb:923:in `connect'
from C:/Ruby22/lib/ruby/2.2.0/net/http.rb:863:in `do_start'
from C:/Ruby22/lib/ruby/2.2.0/net/http.rb:852:in `start'
from C:/Ruby22/lib/ruby/2.2.0/net/http.rb:1375:in `request'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/httparty-0.14.0/lib/httparty/request.rb:118:in `perform'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/httparty-0.14.0/lib/HTTParty.rb:560:in `perform_request'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/httparty-0.14.0/lib/HTTParty.rb:486:in `get'
from C:/Ruby22/lib/ruby/gems/2.2.0/gems/httparty-0.14.0/lib/HTTParty.rb:598:in `get'
from C:/Users/Tom/RubymineProjects/projectone/projectone.rb:7:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'它似乎在使用2.2.0,我试图谷歌如何卸载一个版本,但仍然不确定怎么办?有什么帮助吗?
如果这有帮助的话,我会在Ruby中运行这个脚本。
我正在运行Windows 10。
发布于 2017-05-26 18:16:17
来自:How do I make HTTParty ignore SSL?
在最新的HTTParty中,可以使用“验证”选项禁用SSL验证; HTTParty.get( "#{ @settings.api_server }#{ url }",:验证=> false).parsed_response“
注意:verify => false的使用
https://stackoverflow.com/questions/40941582
复制相似问题