gpt4 book ai didi

java - 使用 ROME 提取提要内容?

转载 作者:搜寻专家 更新时间:2023-11-01 03:12:32 26 4
gpt4 key购买 nike

如何在 Java 中使用 ROME 将内容作为字符串获取某些提要。

目前这就是我得到的

String feedURL = “...”;
SyndFeedInput input = new SyndFeedInput();
SyndFeed feed = input.build(new XmlReader(feedUrl));

System.out.println(feed);

for (final Iterator iter = feed.getModules().iterator(); iter.hasNext();){
System.out.println("\t" + ((Module)iter.next()).getUri());
}

System.out.println("Titles of the " + feed.getEntries().size() + " entries:");
for (final Iterator iter = feed.getEntries().iterator(); iter.hasNext();){
System.out.println("\t" + ((SyndEntry)iter.next()).getContents());
}

那么这个的输出是:

SyndContentImpl.interface=interface com.sun.syndication.feed.synd.SyndContent
SyndContentImpl.type=html
SyndContentImpl.mode=null

SyndContentImpl.value= <p><a href="http://www.flickr.com/people/64539367@N07/">MiscDot</a> posted a photo:</p>

<p><a href="http://www.flickr.com/photos/64539367@N07/5954881384/" title="03a"><img src="http://farm7.static.flickr.com/6024/5954881384_5390838321_m.jpg" width="240" height="240" alt="03a" /></a></p>

但我想要的只是获取内容的字符串:SyndContentsImpl.value

最佳答案

有点像...

for (Iterator<?> entryIter = syndFeed.getEntries().iterator(); entryIter.hasNext();) {
SyndEntry syndEntry = (SyndEntry) entryIter.next();

if (syndEntry.getContents() != null) {
for (Iterator<?> it = syndEntry.getContents().iterator(); it.hasNext();) {
SyndContent syndContent = it.next();

if (syndContent != null) {
String value = syndContent.getValue();
}
}
}
}

关于java - 使用 ROME 提取提要内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6750418/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com