瓦提尔图像处理

发布于 2024-08-01 16:38:13 字数 272 浏览 1 评论 0原文

有没有办法在 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 或只是临时文件的位置)的示例

Is there a way to get an image extension (based on the content-type header) and it's body in Watir?

Here is an example

require 'watir'

zz = Watir::IE.new
zz.goto('http://flickr.com')
image = zz.image(:src => %r/l.yimg.com\/g\/images\//)
puts image

I need to get extension and the contents (base64encoded or just location of a temp file) of the latter image

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

笑梦风尘 2024-08-08 16:38:13
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
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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文