2016-09-19 34 views
0

我想提取标题"Syrian arch razed by ISIS and re-created with 3D "这个HTML代码,其链接"http://www.theverge.com/2016/9/19/12972504/palmyra-arch-of-triumph-isis-3d-replica-new-york-city"从谷歌新闻网站一起:https://www.google.com/search?hl=en&gl=us&tbm=nws&authuser=0&q=technologyJava - Jsoup我将如何提取HTML代码中的标题和链接?

我将非常感谢您的帮助,谢谢,

对不起,我必须有一个像StackOverflow的却是格式化代码古怪

HTML Code

+0

如果它奇怪地将代码格式化,请将其封装在代码块中(在代码前添加一个空行并在每行代码的开头添加4个空格;也可以通过选择代码并按下CTRL + K来完成) – fabian

回答

0

我建议你访问这个link实践这个

 try { 
      // Connect to the web site 
      Document document = Jsoup.connect(url).get(); 
      // Get the html document title 
      title = document.title(); 
      Element link = document.select("a.l _HId"); 
      String s1 = link.absUrl("src"); //Gives you link 
      String s2 = link.text(); //Gives you Required text 
     } catch (IOException e) { 
      e.printStackTrace(); 
     }