机械化返回"connect_nonblock":返回SSL_connect=1 errno=0 状态=SSLv3



我正在尝试抓取Crunchbase页面,但我收到此错误:

ryzal~/Desktop/Sites/scraper$ ruby scraper.rb
/Users/Ryzal/.rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:933:in `connect_nonblock': SSL_connect returned=1 errno=0 state=SSLv3 read server hello A: sslv3 alert handshake failure (OpenSSL::SSL::SSLError)
    from /Users/Ryzal/.rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:933:in `connect'
    from /Users/Ryzal/.rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:863:in `do_start'
    from /Users/Ryzal/.rbenv/versions/2.3.1/lib/ruby/2.3.0/net/http.rb:858:in `start'
    from /Users/Ryzal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:700:in `start'
    from /Users/Ryzal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:631:in `connection_for'
    from /Users/Ryzal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/net-http-persistent-2.9.4/lib/net/http/persistent.rb:994:in `request'
    from /Users/Ryzal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mechanize-2.7.5/lib/mechanize/http/agent.rb:274:in `fetch'
    from /Users/Ryzal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/mechanize-2.7.5/lib/mechanize.rb:464:in `get'
    from scraper.rb:10:in `<main>'

下面是代码:

require 'nokogiri'
require 'mechanize'
require 'json'

agent = Mechanize.new do |a|
  a.ssl_version = :TLSv1
end
page = agent.get "https://www.crunchbase.com/app/search/people/0b543c0d8ea4c95cdf78a48583d501da2a76b26c"
member_links = page.links_with(href: %r{.*/person/w+})
member_links.map do |link|  
    puts member_counter
    member = link.click
    # Get name
    name = member.search('#profile_header_heading').text.strip
    puts "#{name}"
end 

我已经尝试了这两种解决方案:

Ruby Mechanize https 错误机械化获取"错误::ECONNRESET:对等方重置连接 - SSL_connect"

但同样的错误仍然存在。

请帮忙,谢谢!

尝试关注

agent = Mechanize.new
agent.agent.http.verify_mode = OpenSSL::SSL::VERIFY_NONE

相关内容

  • 没有找到相关文章

最新更新