Watirにヒストリーを追加

require 'watir-webdriver'
class Watir::Browser
def visited? url
if @history == nil
return false
end
return @history.index(url) != nil
end
def add_history url
if @history == nil
@history = []
end
@history << url
end
def crawl url
if visited? url
return
end
puts "goto: #{url}"
goto url
add_history url
urls = links.map{|i| i.href}.uniq
urls.each do |u|
crawl(u)
end
end
end
browser = Watir::Browser.new :ff
browser.crawl('http://www.google.com/')
browser.close
view raw gistfile1.rb hosted with ❤ by GitHub

かなり前に書いたものなので間違っているかもしれないです。

コメント

このブログの人気の投稿

git-svnでFILE was not found in commit HASH

[Java] 母音か子音か

ECJをJenkinsに食わせてみた