使用 JavaScript 提取 RSS 提要并设计样式
我想知道是否有人可以帮助我完成我正在做的一个小项目。
我正在构建一个新闻网站,希望从 BBC、WSJ 和华盛顿邮报等网站获取相关的 RSS 提要,而不是简单地将提要显示为列表,我想将它们分成单独的标题并重新设计它们的样式有点像翻板。单击链接后,将在灯箱中显示完整的网站。是否可以使用 JavaScript 来做到这一点,如果可以的话,如何最好地实现呢?
如果社区可以帮助我解决这个问题,那就太好了。
I wonder if someone could help me with a little project im working on.
Im building a news website and would like to pull in relevant RSS feeds from sites such as the BBC, WSJ and the Washington Post and rather than simply display the feeds as a list I would like to split them up into individual headlines and restyle them a bit like flipboard. Once a link is clicked this will display the full website in a lightbox. Is it possible to do this with JavaScript, if so how would it be best achieved?
If the community could help me with this it would be great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
浏览器通常不允许 JavaScript 通过
HttpRequest
(又名 AJAX)方法访问其他域名上的内容,主要是出于安全考虑。但是,您可以通过在自己的服务器上创建网关来检索源,从而有效地规避该问题。
根据您使用的服务器技术,使用
CURL
、HttpWebRequest
或类似机制从前端可通过 AJAX 访问的 URL 检索服务器上的提要称呼。如果不知道您正在使用的框架的具体情况,我无法真正发布示例,但这是通常用于实现您正在寻找的内容的通用公式。
希望这有帮助!
Browsers generally don't allow JavaScript to access content on other domain names via
HttpRequest
(aka AJAX) methods, primarily for security.However, you can effectively circumvent the issue by creating a gateway on your own server to retrieve the feeds.
Depending what server tech you're using, use
CURL
, anHttpWebRequest
or similar mechanism to retrieve the feed on your server, from a url your front end can access via an AJAX call.I can't really post an example without knowing the specifics of the frameworks that you're using, but this is the general formula commonly used to achieve what you're looking for.
Hope this helps!