如何解析HTML收藏文件
3个回答
展开全部
用Jsoup方式,记得导包。
假设已经获取了文档对象Document doc;
获取标签外的时间:
Elements elements = doc.select("span[class]");
for(Element element : elements){
System.out.println(element.text());
}
获取标签内的时间:
Elements elements = doc.select("a[res]");
for(Element element : elements){
System.out.println(element.attr("res").substring(0, 16));//播放时间
System.out.println(element.text());//节目名称
}
假设已经获取了文档对象Document doc;
获取标签外的时间:
Elements elements = doc.select("span[class]");
for(Element element : elements){
System.out.println(element.text());
}
获取标签内的时间:
Elements elements = doc.select("a[res]");
for(Element element : elements){
System.out.println(element.attr("res").substring(0, 16));//播放时间
System.out.println(element.text());//节目名称
}
展开全部
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
Do Not Edit! -->
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 FOLDED ADD_DATE="1436090744">Links</H3>
<DL><p>
<DT><H3 FOLDED ADD_DATE="1436090818"><a href="https://www.baidu.com/s?wd=%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y1ujF9njKbP1P9PH9bm1Tz0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnW0knWfYP1fvPjc4njDdnWR3r0" target="_blank" class="baidu-highlight">新建文件夹</a></H3>
<DL><p>
<DT><H3 FOLDED ADD_DATE="1436090851"><a href="https://www.baidu.com/s?wd=%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y1ujF9njKbP1P9PH9bm1Tz0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnW0knWfYP1fvPjc4njDdnWR3r0" target="_blank" class="baidu-highlight">新建文件夹</a></H3>
<DL><p>
</DL><p>
<!-- This is an automatically generated file.
It will be read and overwritten.
Do Not Edit! -->
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 FOLDED ADD_DATE="1436090744">Links</H3>
<DL><p>
<DT><H3 FOLDED ADD_DATE="1436090818"><a href="https://www.baidu.com/s?wd=%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y1ujF9njKbP1P9PH9bm1Tz0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnW0knWfYP1fvPjc4njDdnWR3r0" target="_blank" class="baidu-highlight">新建文件夹</a></H3>
<DL><p>
<DT><H3 FOLDED ADD_DATE="1436090851"><a href="https://www.baidu.com/s?wd=%E6%96%B0%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y1ujF9njKbP1P9PH9bm1Tz0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnW0knWfYP1fvPjc4njDdnWR3r0" target="_blank" class="baidu-highlight">新建文件夹</a></H3>
<DL><p>
</DL><p>
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2016-03-24 · 做真实的自己 用良心做教育
千锋教育
千锋教育专注HTML5大前端、JavaEE、Python、人工智能、UI&UE、云计算、全栈软件测试、大数据、物联网+嵌入式、Unity游戏开发、网络安全、互联网营销、Go语言等培训教育。
向TA提问
关注
展开全部
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
Do Not Edit! -->
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 FOLDED ADD_DATE="1436090744">Links</H3>
<DL><p>
<DT><H3 FOLDED ADD_DATE="1436090818">新建文件夹</H3>
<DL><p>
<DT><H3 FOLDED ADD_DATE="1436090851">新建文件夹</H3>
<DL><p>
</DL><p>
<!-- This is an automatically generated file.
It will be read and overwritten.
Do Not Edit! -->
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 FOLDED ADD_DATE="1436090744">Links</H3>
<DL><p>
<DT><H3 FOLDED ADD_DATE="1436090818">新建文件夹</H3>
<DL><p>
<DT><H3 FOLDED ADD_DATE="1436090851">新建文件夹</H3>
<DL><p>
</DL><p>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询