Method: Waw::Commands::ProfileCommand#visit

Defined in:
lib/waw/commands/profile_command.rb

#visit(browser, location, visited = {}) ⇒ Object

Recursively visits the whole website



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/waw/commands/profile_command.rb', line 24

def visit(browser, location, visited = {})
  return if ignore?(location, visited)
  visited[location] = true
  browser.location = location
  unless browser.is200
    puts "Hohoho, I've found a lost internal link #{location}"
    return
  else
    puts "Visiting #{location}" if verbose
    browser.all_internal_links.each do |link|
      begin
        visit(browser, link[:href], visited)
      rescue URI::InvalidURIError => ex
        puts "Hohoho, I've found something really wrong #{link[:href]}"
      end
    end
  end 
end