有没有办法在Watir中获得图像扩展名(基于content-type头)和它的正文?
下面是一个例子
require 'watir'
zz = Watir::IE.new
zz.goto('http://flickr.com')
image = zz.image(:src => %r/l.yimg.com\/g\/images\//)
puts image我需要获取后一个图像的扩展名和内容(base64encoded或只是临时文件的位置
发布于 2011-04-08 11:44:27
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)} }
endhttps://stackoverflow.com/questions/1259009
复制相似问题