0
在searchEmails(page)調用後,代碼未執行(將「hey」)放入收穫方法中。我可能錯過了Ruby的一些簡單的東西,因爲我只是回想起它。方法調用後未執行Ruby代碼
def searchEmails(page_to_search)
begin
html = @agent.get(url).search('html').to_s
mail = html.scan(/['.'\w|-]*@+[a-z]+[.]+\w{2,}/).map.to_a
base = page_to_search.uri.to_s.split("//", 2).last.split("/", 2).first
mail.each{|e| @file.puts e+";"+base unless e.include? "example.com" or e.include? "email.com" or e.include? "domain.com" or e.include? "company.com" or e.length < 9 or e[0] == "@"}
end
end
def harvest(url)
begin
page = @agent.get(url)
searchEmails(page)
puts "hey"
rescue Exception
end
end
url="www.example.com"
harvest(url)
你的方法拋出異常。從收穫中刪除救援條款。 – mdrozdziel
另外,不要拯救'例外',拯救你想要的東西。在救援中一般/通用可能導致很難找到錯誤。另外,當詢問代碼中的問題時,我們需要一些可運行的東西。請閱讀「[mcve]」。 –