通过Javascript检索跨域RSS(xml)

时间:2022-08-23 10:02:41

I have seen server side proxy workarounds for retrieving rss (xmls) from cross-domains. In fact this very question addressess my same problem but gives out a different solution.

我看到了服务器端代理工作区,用于从跨域检索rss (xmls)。事实上,这个问题解决了我同样的问题,但给出了一个不同的解决方案。

I have a constraint of do not use a proxy to retrieve rss feeds. And hence the Google AJAX Feed API solution also goes out of picture. Is there a client-only workaround for this problem.

我有一个不使用代理来检索rss提要的约束。因此,谷歌AJAX Feed API解决方案也就不适用了。是否有专门针对客户的解决方案?

JSONP is the solution for requests that respond with JSON output. But here, I have RSS feeds which can respond with pure xml .

JSONP是响应JSON输出的请求的解决方案。但是在这里,我有RSS提要,它可以用纯xml进行响应。

How do I solve the problem.

我如何解决这个问题。

5 个解决方案

#1


4  

Use something like Yahoo! Pipes to serve as your proxy and translate the RSS XML into a JSON response.

使用类似Yahoo !管道作为代理,将RSS XML转换成JSON响应。

Here is an article with instructions and code samples that explains how to do it: Yahoo Pipes--RSS without Server Side Scripts.

这里有一篇文章,介绍了如何实现这一点:Yahoo Pipes—没有服务器端脚本的RSS。

#2


1  

If you have control over both domains, you can try a cross-domain scripting library like EasyXDM, which wraps cross-browser quirks and provides an easy-to-use API for communicating in client script between different domains using the best available mechanism for that browser (e.g. postMessage if available, other mechanisms if not).

如果您对这两个域都有控制,您可以尝试使用一个跨域脚本库,比如EasyXDM,它封装了跨浏览器的怪癖,并提供了一个易于使用的API,用于使用该浏览器的最佳可用机制在不同域之间通信(例如,如果可用,则使用postMessage,否则使用其他机制)。

Caveat: you need to have control over both domains in order to make it work (where "control" means you can place static files on both of them). But you don't need any server-side code changes.

注意:您需要对两个域进行控制,以使其工作(“control”意味着您可以将静态文件放在两个域上)。但是您不需要任何服务器端代码更改。

Another Caveat: there are security implications here-- make sure you trust the other domain's script!

另一个警告:这里有安全问题——确保您信任其他域的脚本!

#3


0  

Right now there really isn't a cross-platform solution for cross-site scripting. Do you have control or access to the RSS feeds? If so, why not simply respond with JSON and use JSONP?

目前还没有跨平台的跨站点脚本编程解决方案。你能控制或访问RSS提要吗?如果是,为什么不简单地用JSON响应并使用JSONP呢?

There are other things coming down the pike with HTML5, like cross-site messaging (referred to as Cross-Document Messaging) that may be capable of delivering a payload of XML, but last time I checked, they hadn't even fully decided on a size limit for the messaging.

HTML5还带来了其他一些东西,比如跨站点消息传递(跨文档消息传递),它们可能能够交付XML的有效负载,但上次我检查时,它们甚至还没有完全确定消息的大小限制。

You can see the spec here: http://dev.w3.org/html5/spec/Overview.html#crossDocumentMessages

您可以在这里看到规范:http://dev.w3.org/html5/spec/Overview.html# crossdocumentmessage

#4


0  

A solution for cross-domain calls without a server-side proxy is to use a SWF component. You can script yourself one or use the readily available FLSend

没有服务器端代理的跨域调用的解决方案是使用SWF组件。您可以自己编写一个脚本或使用现成的FLSend

The component uses ActionScript's URLRequest to call remote domains and ExternalInterface to communicate with the JavaScript methods that render your content.

该组件使用ActionScript的URLRequest调用远程域和ExternalInterface,与呈现内容的JavaScript方法进行通信。

#5


0  

The only way I can think of would be to embed a signed java applet on the webpage to retrive the xml and use javascript to interface with that. I'm not even 100% certain what the java security model is for that at present though but I think it would work.

我能想到的唯一方法是在网页上嵌入一个签名的java applet,以检索xml并使用javascript与之交互。目前我甚至不能100%确定java安全模型是什么,但是我认为它可以工作。

#1


4  

Use something like Yahoo! Pipes to serve as your proxy and translate the RSS XML into a JSON response.

使用类似Yahoo !管道作为代理,将RSS XML转换成JSON响应。

Here is an article with instructions and code samples that explains how to do it: Yahoo Pipes--RSS without Server Side Scripts.

这里有一篇文章,介绍了如何实现这一点:Yahoo Pipes—没有服务器端脚本的RSS。

#2


1  

If you have control over both domains, you can try a cross-domain scripting library like EasyXDM, which wraps cross-browser quirks and provides an easy-to-use API for communicating in client script between different domains using the best available mechanism for that browser (e.g. postMessage if available, other mechanisms if not).

如果您对这两个域都有控制,您可以尝试使用一个跨域脚本库,比如EasyXDM,它封装了跨浏览器的怪癖,并提供了一个易于使用的API,用于使用该浏览器的最佳可用机制在不同域之间通信(例如,如果可用,则使用postMessage,否则使用其他机制)。

Caveat: you need to have control over both domains in order to make it work (where "control" means you can place static files on both of them). But you don't need any server-side code changes.

注意:您需要对两个域进行控制,以使其工作(“control”意味着您可以将静态文件放在两个域上)。但是您不需要任何服务器端代码更改。

Another Caveat: there are security implications here-- make sure you trust the other domain's script!

另一个警告:这里有安全问题——确保您信任其他域的脚本!

#3


0  

Right now there really isn't a cross-platform solution for cross-site scripting. Do you have control or access to the RSS feeds? If so, why not simply respond with JSON and use JSONP?

目前还没有跨平台的跨站点脚本编程解决方案。你能控制或访问RSS提要吗?如果是,为什么不简单地用JSON响应并使用JSONP呢?

There are other things coming down the pike with HTML5, like cross-site messaging (referred to as Cross-Document Messaging) that may be capable of delivering a payload of XML, but last time I checked, they hadn't even fully decided on a size limit for the messaging.

HTML5还带来了其他一些东西,比如跨站点消息传递(跨文档消息传递),它们可能能够交付XML的有效负载,但上次我检查时,它们甚至还没有完全确定消息的大小限制。

You can see the spec here: http://dev.w3.org/html5/spec/Overview.html#crossDocumentMessages

您可以在这里看到规范:http://dev.w3.org/html5/spec/Overview.html# crossdocumentmessage

#4


0  

A solution for cross-domain calls without a server-side proxy is to use a SWF component. You can script yourself one or use the readily available FLSend

没有服务器端代理的跨域调用的解决方案是使用SWF组件。您可以自己编写一个脚本或使用现成的FLSend

The component uses ActionScript's URLRequest to call remote domains and ExternalInterface to communicate with the JavaScript methods that render your content.

该组件使用ActionScript的URLRequest调用远程域和ExternalInterface,与呈现内容的JavaScript方法进行通信。

#5


0  

The only way I can think of would be to embed a signed java applet on the webpage to retrive the xml and use javascript to interface with that. I'm not even 100% certain what the java security model is for that at present though but I think it would work.

我能想到的唯一方法是在网页上嵌入一个签名的java applet,以检索xml并使用javascript与之交互。目前我甚至不能100%确定java安全模型是什么,但是我认为它可以工作。