Trying to get content:encoded with jfeed

﹥>﹥吖頭↗ 提交于 2019-12-25 11:49:12

问题


I can get a successful response with the RSS I am trying to pull using jfeed, however, the thing I really want is the content. [content:encoded] I need this so I can grab the first image from each post.

I figured it would be easy to update jfeed to do this, but nothing I try seems to get it. The most obvious attempt was to add:

item.content = jQuery(this).find('content\:encoded').eq(0).text();

but this returns an empty string. I'd really appreciate a push in the right direction, thanks all!


回答1:


Caveat: Don't know jfeed, but I've used lots of feed parsers.

With that caveat, why do you prefix the colon with a slash? You should not need to do that.

Also, some feed parsers are not namespace aware. Since content is a namespace prefix, it's possible that jfeed is not able to find() on that. In that case, you would need to try .find('encoded'), omitting the namespace prefix.

It's also possible that that feed (or certain items in that feed) don't have the content:encoded element. That's an extension of RSS and not a required element.



来源:https://stackoverflow.com/questions/9451202/trying-to-get-contentencoded-with-jfeed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!