1

ああ、初投稿…

私は Google Feed API-v1 (https://developers.google.com/feed/v1/) を使用しており、「publishedDate」が空白の RSS フィードがいくつかあります。つまり、「:」は、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 では以下の publishedDate にアクセスできます。results は、Google からの json レスポンスです。

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

それが役立つことを願っています。

于 2012-06-03T03:50:41.993 に答える