使用jsoup获取html内容

时间:2014-12-20 03:43:24

标签: javascript jsoup

我无法使用jsoup从以下内容获取数据。你能建议我如何使用jsoup获取标题,日期,href,href的描述。请建议我使用javascript如何处理它。最后,我应该有两行,上面指定的列位于div标签下。我用这种方式尝试过它

Jsoup = org.jsoup.Jsoup;
Whitelist = org.jsoup.safety.Whitelist;
OutputSettings = org.jsoup.nodes.Document.OutputSettings;
EscapeMode = org.jsoup.nodes.Entities.EscapeMode;
doc = Jsoup.parse(html);
os = OutputSettings().escapeMode(EscapeMode.xhtml).charset("utf-8"); 
var title = doc.outputSettings(os).select("a[href]").text();
var links = doc.outputSettings(os).select("a").attr("href"); 

但在写完之后我把所有东西都放在了一排。除此之外,我们还可以获得超链接描述。我希望以下数据有两行。

<div class="section"> 
<div class="row"> 
 <div class="col-sm-12"> 
  <p>Dec 18, 2014, 11:00 ET</p> 
  <ul> 
   <li><a title="SANS Honors People Who Made a Difference in Cybersecurity in 2014" href="http://www.prnewswire.com/news-releases/sans-honors-people-who-made-a-difference-in-cybersecurity-in-2014-300011928.html">SANS Honors People Who Made a Difference in Cybersecurity in 2014</a></li> 
   <li> SANS Institute is pleased to announce the winners of the SANS 2014 Difference Makers awards. While the headlines focus on security breaches, there are thousands of security practitioners out there who are quietly succeeding and keeping their companies and customers safe from attacks. The SANS... </li> 
   <li>More news about: <a title="SANS Institute">SANS Institute</a> </li> 
  </ul> 
 </div> 
</div> 
<div class="row"> 
 <div class="col-sm-9"> 
  <p>Dec 17, 2014, 07:00 ET</p> 
  <ul> 
   <li><a title="Microsemi's Ultra-secure SmartFusion2 SoC FPGAs and IGLOO2 FPGAs Recognized on EDN's List of Hot 100 Products of 2014" href="http://www.prnewswire.com/news-releases/microsemis-ultra-secure-smartfusion2-soc-fpgas-and-igloo2-fpgas-recognized-on-edns-list-of-hot-100-products-of-2014-300010576.html">Microsemi's Ultra-secure SmartFusion2 SoC FPGAs and IGLOO2 FPGAs Recognized on EDN's List of Hot 100 Products of 2014</a></li> 
   <li>  Microsemi Corporation (Nasdaq: MSCC), a leading provider of semiconductor solutions differentiated by power, security, reliability and performance, today announced its SmartFusion2® SoC FPGAs and IGLOO2® FPGAs were recognized among the Hot 100 Products of 2014 by EDN. Among the many... </li> 
   <li>More news about: <a title="Microsemi Corporation">Microsemi Corporation</a> </li> 
  </ul> 
 </div> 
 <div class="col-sm-3"> 
  <a title="Microsemi's Ultra-secure SmartFusion2 SoC FPGAs and IGLOO2 FPGAs Recognized on EDN's List of Hot 100 Products of 2014" href="http://www.prnewswire.com/news-releases/microsemis-ultra-secure-smartfusion2-soc-fpgas-and-igloo2-fpgas-recognized-on-edns-list-of-hot-100-products-of-2014-300010576.html"> <img src="http://photos.prnewswire.com/prnthumb/20110909/MM66070LOGO" alt="Microsemi Corporation."> </a> 
 </div> 
</div> 

0 个答案:

没有答案