私はサイトのリストを調べ、Watir を使用して各サイトに移動し、各ページのソース コードで何かを探しています。ただし、約 20 または 30 のサイトの後、特定のページをロードするときにブラウザーがタイムアウトし、スクリプトが壊れて、次のエラーが発生します。
rbuf_fill: 実行期限切れ (Timeout::Error)
タイムアウトを検出し、中断したところからサイトのテストを再開する方法を実装しようとしていますが、問題があります。これは私のコードです:
ie = Watir::Browser.new :firefox, :profile => "default"
testsite_array = Array.new
y=0
File.open('topsites.txt').each do |line|
testsite_array[y] = line
y=y+1
end
total = testsite_array.length
count = 0
begin
while count <= total
site = testsite_array[count]
ie.goto site
if ie.html.include? 'teststring'
puts site + ' yes'
else
puts site + ' no'
end
rescue
retry
count = count+1
end
end
ie.close