Google api 如何使用GoogleAPI或任何其他技术解析RSS

Google api 如何使用GoogleAPI或任何其他技术解析RSS,google-api,rss,Google Api,Rss,我想解析下面提到的RSS,以获得标题、描述、图像和日期。目前,我可以得到所有其他细节,除了图像。我正在使用谷歌api提要解析rss。请在这种情况下,任何人都能告诉我。 RSS: //Google提要API:https://developers.google.com/feed/ //灵感:http://designshack.net/articles/javascript/build-an-automated-rss-feed-list-with-jquery/ 函数parseFeed(url、容

我想解析下面提到的RSS,以获得标题、描述、图像和日期。目前,我可以得到所有其他细节,除了图像。我正在使用谷歌api提要解析rss。请在这种情况下,任何人都能告诉我。 RSS:

//Google提要API:https://developers.google.com/feed/
//灵感:http://designshack.net/articles/javascript/build-an-automated-rss-feed-list-with-jquery/
函数parseFeed(url、容器){
$.ajax({
url:document.location.protocol+'//ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=5&callback=?&q='+encodeURIComponent(url),
数据类型:“json”,
成功:功能(数据){
//在控制台中记录对象数据
日志(data.responseData.feed);
//在容器中附加提要链接和标题
$(容器)。附加(“”);
$(容器).append(“”+data.responseData.feed.title+“”);
//对于每个条目*
$.each(data.responseData.feed.entries、函数(键、值){
//*创建新的日期对象并传入输入日期
var date=新日期(value.publishedDate);
//var thumbnail=entry.mediaGroups[0]。内容[0]。url;
//*创建月数组
var月数=新阵列(12);
月[0]=“一月”;
月[1]=“二月”;
月[2]=“三月”;
月[3]=“4月”;
月[4]=“五月”;
月[5]=“六月”;
月[6]=“7月”;
月[7]=“8月”;
月[8]=“9月”;
月[9]=“10月”;
月[10]=“11月”;
月[11]=“12月”;
//*解析月、日和年
var month=date.getMonth();
var day=date.getDate();
var year=date.getFullYear();
//*分配输入变量
var title='';
变量时间='

'+月[月]+''+日+,'+年+'

'; var snippet='

'+value.contentSnippet+'

'; var img='

'+value.thumbnail+'

'; 变量项=“”+标题+时间+片段+“”; //*将整个条目附加到容器中 $(容器)。追加(条目); }); }, //如果有错误* 错误:函数(错误抛出){ //*在控制台中记录错误消息 console.log(错误抛出); //*显示错误消息 警报(“休斯顿,我们有问题。”); } }); } $(文档).ready(函数(){ parseFeed('https://news.google.com/news/feeds?pz=1&cf=all&ned=en&hl=in&q=aishwarya%20rai&output=rss","cstricks",; });
只需将此添加到脚本中即可

var content = document.createElement("content");
content.innerHTML = value.content; 
var images = "";
$(content).find('img').each(function() {  
    images += this.outerHTML;
});
var img = '<p class="snippet">' + images + '</p>';
var content=document.createElement(“内容”);
content.innerHTML=value.content;
var images=“”;
$(content).find('img').each(function(){
images+=this.outerHTML;
});
var img='

'+images+'

';
答案与这里相同:


代码笔示例:

您的问题不清楚,您使用的是什么编程语言?你的代码呢?我在用jquery。下面是我的代码。太棒了,连我看起来都一样。非常感谢Janih:)
var content = document.createElement("content");
content.innerHTML = value.content; 
var images = "";
$(content).find('img').each(function() {  
    images += this.outerHTML;
});
var img = '<p class="snippet">' + images + '</p>';