Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java jsoup从超链接中提取特定属性_Java_Jsoup - Fatal编程技术网

Java jsoup从超链接中提取特定属性

Java jsoup从超链接中提取特定属性,java,jsoup,Java,Jsoup,我在网页中有一些超链接,我想提取其中的属性标题 我试过了 select("a[href]").attr("title") 但我什么也得不到 编辑 这里是完整的div 试用码 Elements es = doc.select("div.mini-placard") for(Element e:es) { System.out.println( e.select("span.align-image-vert

我在网页中有一些超链接,我想提取其中的属性标题

我试过了

 select("a[href]").attr("title") 
但我什么也得不到

编辑

这里是完整的div 试用码

 Elements es = doc.select("div.mini-placard")
 for(Element e:es) 
 {
    System.out.println(  e.select("span.align-image-vertically").select("a").attr("title"));
  }

没有输出

请正确提取链接元素,然后检查链接元素的属性,如下所示:

String html = "<p>An <a href='http://example.com/' title='hi'><b>example</b></a> link.</p>";
Document doc = Jsoup.parse(html);
Element link = doc.select("a").first();

String text = doc.body().text(); // "An example link"
String linkHref = link.attr("href"); // "http://example.com/"
String linkTitle = link.attr("title"); // 'hi'

不,你的代码不能解决问题。它的工作原理与我的代码相同。您的预期输出是什么?发布代码片段而不是截图属性标题包含它一个标题已经写在这里你能发布你用html片段尝试过的内容吗?这将很容易排序。@soorapadman我刚刚发布了它。您能发布url或HTML片段吗?没有您试图解析的屏幕截图?