gpt4 book ai didi

ruby - 使用 ruby​​ mechanize gem 时出现 SSL Reuse 错误

转载 作者:行者123 更新时间:2023-12-04 16:22:28 24 4
gpt4 key购买 nike

在出现以下错误之前,我的 Mechanize 脚本运行了大约 3 个小时:

C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent- 
2.7/lib/net/http/persistent/ssl_reuse.rb:29:in `initialize':
A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because
connected host has failed to respond. - connect(2) (Errno::ETIMEDOUT)

我假设这是因为它已经运行了 2-3 个小时,但想知道是否有人对错误有任何特别的见解

这是我的脚本
require 'rubygems'
require 'mechanize'

def next_button(web_page)
web_page.page.search('.next a').each do |next_button|
web_page.click(next_button)
web_page.page.search('.listing_content').each |info|
get_info(info)
end
next_button(web_page)
end
end

def get_info(info)
infos = info.at_css('.url').text.strip
address = info.css('.street-address').text.strip
city = info.css('.locality').text.strip
state = info.css('.region').text.strip
zip = info.css('.postal-code').text.strip
end

web_page = Mechanize.new
web_page.user_agent_alias = "Linux Firefox"
web_page.get(HOME_URL)

web_page.page.search('.page-navigation a').each do |pagination_link|
web_page.page.search('.categories-list a').each do |link|

web_page.click(link)
web_page.page.search('.listing_content').each do |info|

get_info(info)
end
next_button(web_page, worksheet)
end

web_page.click(pagination_link)
end

提前感谢您的任何帮助。

最佳答案

在我看来,持久连接比它们的值(value)更麻烦。当我遇到这种情况时,我会检查以确保我拥有最新版本的 Mechanize ,如果仍然发生,我会回退到不使用持久连接的 Mechanize 1.0.0。

关于ruby - 使用 ruby​​ mechanize gem 时出现 SSL Reuse 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11314616/

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