2016-09-19 52 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(); 
     }