3

I have just installed ruby and have been following Ruby tutorials. I started this tutorial: https://www.distilled.net/resources/web-scraping-with-ruby-and-nokogiri-for-beginners/

Where I got the SSL error so I used the guide at http://guides.rubygems.org/ssl-certificate-update/

My problem is though that my version is ruby 2.6.7 when I ask for the version but when I run this code:

require 'Nokogiri'
require 'HTTParty'
require 'JSON'
require 'Pry'
require 'csv'

page = HTTParty.get('https://google.com/')
Pry.start(binding)

I get this error

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>'

It seems to be using 2.2.0 still, I tried to google how to uninstall a version but still unsure what to do? Any help?

I ran the script in Ruby Mine if that helps.

I am running Windows 10.

FeifanZ
  • 16,250
  • 7
  • 45
  • 84
Tommy
  • 31
  • 1
  • 3
  • The current stable version of Ruby is `2.3.3` … there is no Ruby `2.6.7` – FeifanZ Dec 02 '16 at 23:05
  • To clarify, `gem -v` is 2.6.7 and `ruby -v` is 2.2? – orde Dec 02 '16 at 23:05
  • That `SSL_connect` error means that it connected to a server, but the server didn't respond with a valid SSL certificate. You should determine why that is the case … perhaps something in your network configuration? – FeifanZ Dec 02 '16 at 23:06
  • When I do them I get: C:\Users\Tom>ruby -v ruby 2.2.5p319 (2016-04-26 revision 54774) [i386-mingw32] C:\Users\Tom>gem -v 2.6.7 – Tommy Dec 02 '16 at 23:13
  • 1
    Thank you FeifanZ! I replaced https with http and it now works. Thanks for the SSL understanding – Tommy Dec 02 '16 at 23:21

1 Answers1

2

From: How do I make HTTParty ignore SSL?

In the latest HTTParty, you can use the verify option to disable SSL verification;

HTTParty.get( "#{ @settings.api_server }#{ url }", :verify => false).parsed_response"

Note the use of :verify => false

Community
  • 1
  • 1