【发布时间】:2012-10-10 08:36:45
【问题描述】:
我已经进行了一次网络爬虫,并收集了很多 html 和 xml 页面。我的目的是从中提取所有 Rss/Atom 提要。我注意到许多网站只是在标题上使用“text/xml”作为内容类型,因此我无法识别来自任何其他类型 xml 的提要。于是我写了这段代码:
public boolean isFeed(String content){
Document doc = Jsoup.parse(content);
Elements feed = doc.getElementsByTag("feed");
Elements channel = doc.getElementsByTag("channel");
if(feed!=null){
if(!feed.isEmpty()){
return true;
}
}
if(channel!=null){
if(!channel.isEmpty()){
return true;
}
}
return false;
}
这里有什么遗漏吗?有什么问题吗?
【问题讨论】: