如何在Java中将< img ... in html转换为byte [] [英] How to convert an <img... in html to byte [] in Java

查看:127
本文介绍了如何在Java中将< img ... in html转换为byte []的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在HtmlUnit无头浏览器中打开了一个网页。现在该网页包含图像html标记,如下所示:

I have opened a webpage in HtmlUnit headless browser. Now that webpage contains a image html tag as follows:

<img src="..." />

所以我只想要那个图像。但问题是图像的相同src URL显示差异。每次都是形象。意思是,如果我们刷新img src URL,那么它会显示diff。每次都是图像。

So I want that image only. But the problem is that the same src URL of the image shows diff. image each time. Means, if we refresh the img src URL, then it shows diff. image each time.

那么如何获取html页面上显示的图像。

So how to get the image that is displayed on the html page.

推荐答案

当您获得 HTMLPage ,你必须通过其中一种方法获得图像。然后,您可以获得 HtmlImage ,保存为文件。您只需稍后分析此文件。

When you get the HTMLPage, you have to get the image through one of its method. You can then get an HtmlImage, which can be saved as a file. You'll just have to analyse this file later.

这篇关于如何在Java中将&lt; img ... in html转换为byte []的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆