0
我是新來的HTML,並試圖通過嘗試從HTML字符串中檢索數據來了解HTML標記。我如何使用Jsoup從html中檢索數據
<li>
<div class="item" data-youtube_code="code_for_youtuber" data-feature_code="data" data-feature_url="/movies/Truman">
<div class="title">
<span>the title of the video</span>
</div>
<div class="image">
<img src="/media/image.png" data-src="http://url_of_image.jpg" alt="">
</div>
</div> </li>
我使用Java Jsoup庫,到目前爲止,我管理使用提取<span>
內容:
Document doc = Jsoup.connect("http://www.yesplanet.co.il/movies").get();
System.out.println(doc.html());
Elements elem = doc.select(".item").text();
我怎樣才能得到其他的東西,如data-youtube_code
和img src
。
編輯: 例如:
System.out.println("doc...data-youtube_code");//some code that retrieves
//data-youtube_code. The ouptup will be "code_for_youtuber"
System.out.println("data-src")
//some code that retrieves
//data-src. The ouptup will be "http://url_of_image.jpg"
你能分享什麼是您預期的輸出? – soorapadman
謝謝你讓我注意到,編輯 – ben