Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法获得图像扩展名(基于内容类型标题)及其在 Watir 中的正文?
这是一个例子
require 'watir' zz = Watir::IE.new zz.goto('http://flickr.com') image = zz.image(:src => %r/l.yimg.com\/g\/images\//) puts image
我需要获取后一个图像的扩展名和内容(base64encoded 或只是临时文件的位置)
require 'watir-webdriver' require 'open-uri' b = Watir::Browser.new :firefox b.goto "http://altentee.com" b.images.each do |img| uri = URI.parse(img.src) open(uri) { |file| puts file.content_type; open('/tmp/file', 'wb') { |tmp| tmp.write(file.read)} } end