javascript - 无法使用Axios和Vue.Js从其他网站检索rss xml信息

标签 javascript xml vue.js rss axios

我有多个具有 RSS XML 提要的网站,我想将它用于我的 Web 应用程序。我尝试使用 Axios 函数(如下所示)。

axios.get('https://www.15min.lt/rss/sportas')
     .then((response) => {
          loading = false;
          this.dataReceived = response;
          console.log(response);
     })
     .catch((error) => {
          loading = false;
          this.errorReceived = error;
          console.log({ error });
     });

但是我得到的只是

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

我尝试将所有项目上传到服务器,因为我发现这个错误可能是因为在个人机器上本地使用它而导致的。但我得到的结果是一样的,除了我得到的不是错误的“null”,而是我的域名。

我尝试了其他基于 Vue.js 的 Web 应用程序进行测试,或者这是我的附带问题,或者网站只是阻止了与 RSS 提要的任何连接。但是http://qreader.qcode.in Web 应用程序与我的链接一起工作,我确信它可以工作。但我不知道如何让它发挥作用。

在我的项目中,我使用了 Vue.js、Axios 和 jQuery。

最佳答案

我自己找到了最简单的方法。有一个网站 - https://cors.now.sh这有助于提出这些请求。

就像下面的例子一样使用它:

XML Retrieve URL - https://cors.now.sh/https://example.com/rss-xml-link

关于javascript - 无法使用Axios和Vue.Js从其他网站检索rss xml信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47599433/

相关文章:

xml - XPath选择没有“isNull”的值

arrays - How do I preselect a vue-multiselect option when options is an array of objects?

javascript - Google map 自动完成 - 最多 3 个字符类型

xml - XSLT-FO for 每个

c# - XML序列化和反序列化与内存流

javascript - vue-at 中的 V 模型不起作用

javascript - 谷歌地图未捕获类型错误 : Cannot read property 'firstChild' of null in vue js html?

javascript - 类型错误 : Cannot read property 'length' of undefined react

在 DOM 中替换的 Javascript

c# - 如何更改浏览器的后退按钮功能,类似于 asp.net 中的电子商务网站