jSoup从img标签获取标题 [英] jSoup get title from img tag

查看:146
本文介绍了jSoup从img标签获取标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种情况,需要从如下所示的img标签中提取标题.

I have a scenario where I need to pull the title from a img tag like below.

<img alt="Bear" border="0" src="/images/teddy/5433.gif" title="Bear"/>

我能够获取图片网址.但是我如何从img标签获得标题. 从上面的标题="bear".我要提取它.

I was able to get the image url. But how do i get the title from the img tag. From above title = "bear". I want to extract this.

推荐答案

使用

Use Element#attr() to extract arbitrary element attributes.

Element img = selectItSomehow();
String title = img.attr("title");
// ...

另请参见:

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