62,616
社区成员
发帖
与我相关
我的任务
分享
<li class="book_list_info">
<h3>
<span>中文图书</span>
<a href="item.php?marc_no=0001355091">
<b>1.<em style="color:#F00;">暮光之城</em>,暮色.第2版</b></a>
I712.45/4827-1=2/1
</h3>
<p> <span>馆藏复本:1 <br>
可借复本:1</span> (美) 斯蒂芬妮·梅尔著 <br>
接力出版社 2012 <br>
<img src="../tpl/images/star0.gif" title="总体评分及评价人数">(0)
<a href="item.php?marc_no=0001355091" class="tooltip" onmouseover="showDetail('0001355091')"
onmouseout="hideDetail('0001355091')">馆藏<s></s>
</a>
</p>
<div id="detail0001355091" style="display:none;">加载中...</div>
</li>
Document doc=Jsoup.parse(你的html);
Element element=doc.select("li.book_list_info p").first();
String html=element.html();
Matcher m=Pattern.compile("(?s)(?<=</span>).*?(?=<img)").matcher(html);
if(m.find()){
System.out.println(Arrays.asList(m.group().split("<br(\\s*/)?>")));
}
/*
* 根据开头的字符结尾的字符以及之间的字符返回匹配的字符串
* str 待匹配的字符串,begin开始匹配的字符串,key匹配的中间字符,end匹配的结束字符
*/
public static String[] match(String str, String begin,String key,String end)
{
String [] strMc = new String[9];
int beginIndex = str.indexOf(begin);
int endLength = end.length();
int endIndex = str.indexOf(end,beginIndex+begin.length())+endLength;
int i = 0;
while(-1!=beginIndex&&-1!=endIndex)
{
String sub = str.substring(beginIndex, endIndex);
if(-1!=sub.indexOf(key))
{
strMc[i] = new String(str.substring(beginIndex, endIndex+endLength));
i++;
}
beginIndex = str.indexOf(begin, endIndex);
endIndex = str.indexOf(end, beginIndex);
}
return strMc;
}