首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何以编程方式从博客站点查找博客提要URL

如何以编程方式从博客站点查找博客提要URL
EN

Stack Overflow用户
提问于 2012-02-27 12:37:19
回答 1查看 846关注 0票数 3

我们使用以下代码来读取RSS | ATOM提要,有没有办法找到博客提要的RSS | ATOM URL给博客网站(例如for http://my.typepad.com or http://occupylosangeles.org/)。这应该类似于google.com/reader所做的事情。

代码语言:javascript
复制
import com.sun.syndication.feed.atom.Feed;
import com.sun.syndication.feed.module.Module;
import com.sun.syndication.feed.synd.SyndCategory;
import com.sun.syndication.feed.synd.SyndContent;
import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.feed.synd.SyndFeedImpl;
import com.sun.syndication.fetcher.FeedFetcher;
import com.sun.syndication.fetcher.FetcherEvent;
import com.sun.syndication.fetcher.FetcherListener;
import com.sun.syndication.fetcher.impl.FeedFetcherCache;
import com.sun.syndication.fetcher.impl.HashMapFeedInfoCache;
import com.sun.syndication.fetcher.impl.HttpURLFeedFetcher;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;
    FeedFetcher fetcher = new HttpURLFeedFetcher(feedInfoCache);
    // register listener to feed
    FetcherEventListenerImpl listener = new FetcherEventListenerImpl();
    fetcher.addFetcherEventListener(listener);

    // Mechanism to read feeds via Rome Fetcher
    SyndFeed feed = fetcher.retrieveFeed(new URL(feedURL));
EN

回答 1

Stack Overflow用户

发布于 2012-10-17 20:08:29

在罗马似乎没有这样的功能,但有一种方法。在HTML源代码中查找特定元素:

代码语言:javascript
复制
<link rel="alternate" type="application/rss+xml" href="http://url-of-an-rss-feed">

rel和URL值应该完全像这样,href将包含提要的type

还有一种方法可以通过发送如下请求来使用AJAX Feed API

代码语言:javascript
复制
http://ajax.googleapis.com/ajax/services/feed/lookup?v=1.0&q=YOUR-PAGE-URL

source

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9460135

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档