gpt4 book ai didi

ruby - Mechanize 返回 `connect_nonblock' : SSL_connect returned=1 errno=0 state=SSLv3

转载 作者:太空宇宙 更新时间:2023-11-03 14:43:07 25 4
gpt4 key购买 nike

我正在尝试抓取 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 error Mechanize getting "Errno::ECONNRESET: Connection reset by peer - SSL_connect"

但仍然存在同样的错误。

请帮忙,谢谢!

最佳答案

尝试关注

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

关于ruby - Mechanize 返回 `connect_nonblock' : SSL_connect returned=1 errno=0 state=SSLv3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41559462/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com