从URL集中提取原子提要

时间:2014-01-28 15:20:37

标签: java rome

我有一个庞大的URL列表,我的任务是将它们提供给应该吐出原子内容的java代码。是否有API库或如何访问它们?我尝试了下面的代码,但它没有显示任何输出。我不知道出了什么问题?

try {
URL url = new URL("https://www.google.com/search?hl=en&q=robbery&tbm=blg&
output=atom");
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(url));
System.out.println("Feed Title: " + feed.getTitle());
for (SyndEntry entry : (List<SyndEntry>) feed.getEntries())
{
System.out.println("Title: " + entry.getTitle());
System.out.println("Unique Identifier: " + entry.getUri());
System.out.println("Updated Date: " + entry.getUpdatedDate());
for (SyndLinkImpl link : (List<SyndLinkImpl>) entry.getLinks())
{
System.out.println("Link: " + link.getHref());}           
for (SyndContentImpl content : (List<SyndContentImpl>) entry.getContents())
{
System.out.println("Content: " + content.getValue());
}

for (SyndCategoryImpl category : (List<SyndCategoryImpl>) entry.getCategories())
{
System.out.println("Category: " + category.getName());
}}}
catch (Exception ex) 
{
}

1 个答案:

答案 0 :(得分:1)

您可以使用罗马(http://rometools.org)处理原子Feed。