[英]SSL Reuse error when using ruby mechanize gem
在出現以下錯誤之前,我的機械化腳本運行了大約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
感謝您的任何幫助。
在我看來,持久連接比它們值得的麻煩更多。 當發生這種情況時,我會檢查以確保我具有最新版本的機械化,如果仍然發生,我會退回到機械化1.0.0,它不使用持久連接。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.