1

啊啊啊我的第一篇文章...

我正在使用 Google Feed API-v1 (https://developers.google.com/feed/v1/) 并且有一些 RSS 提要,其中“publishedDate”为空白,即 - “:”,这意味着 RSS 发布者是没有将文章日期传递到他们的 RSS 提要中。例如,我从http://www.globest.com/index.xml提取文章,而他们的提要没有“publishedDate”或“pubDate”;但是,当我将 www.globest.com/index.xml 放入 Google 阅读器时,标题旁边会出现文章日期。我了解 Google 阅读器中文章旁边显示的日期是“收到”或“发布”日期。Google 在此处解释术语http://support.google.com/reader/bin/answer.py?hl=en&answer=78728

所以我的问题.... Google Feed API v1 中是否有一种方法可以获取“收到”或“发布”日期?如果是,如何。如果没有,大约 v0?

我正在使用 Java 和 JSON,我的代码如下:

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.URL;
    import java.net.URLConnection;
    import net.sf.json.JSONObject;

    public class FeedTester 
    {

        public static void main(String[] args) throws IOException 
        {
            String loadBaseURL = "https://ajax.googleapis.com/ajax/services/feed/load";
            String googleRSSURL = "?v=1.0&q=";
            String testRSSURL = "http://www.globest.com/index.xml";
            String extra = "&callback=CB1&num=10";

            URL url = new URL(loadBaseURL+googleRSSURL+testRSSURL+extra);
            URLConnection connection = url.openConnection();
            connection.addRequestProperty("Referer", "www.YOURSITE.com");

            String line;
            StringBuilder builder = new StringBuilder();
            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            while((line = reader.readLine()) != null)
            {
                    builder.append(line);
            }

            JSONObject json = new JSONObject();
            json.put("values", builder.toString());

            System.out.println(json.get("values"));
        }//end main
    }//end FeedTester
4

1 回答 1

0

我不确定 Java,但在 Python 中,您可以访问下面的发布日期。结果是来自谷歌的 json 响应。

for entries in results['responseData']['feed']['entries']:  
    print entries['publishedDate']

希望有帮助。

于 2012-06-03T03:50:41.993 回答