World Community Grid API docs表示可以使用JSON或XML获取团队数据。我只是通过点击xml=true
或format=xml
设法获得XML。 I can view that data directly in my browser
大。现在我需要将它提取到我自己的网站页面上。但是,当我尝试使用d3.xml()
获取数据时,浏览器控制台会显示:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
不太好。 WCG标题的进一步调查显示:
Server: Apache
X-Powered-By: Servlet/3.0
Pragma: No-cache
Cache-Control: no-cache,no-store,max-age=0
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Length: 17684
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Referrer-Policy: no-referrer-when-downgrade
Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://www.googletagmanager.com https://www.google-analytics.com/analytics.js; style-src 'self' 'unsafe-inline' 'unsafe-eval' https://www.googletagmanager.com; img-src * data:; frame-src 'self' https://www.youtube.com https://www.youtube-nocookie.com;
Content-Type: text/xml; charset=UTF-8
Content-Language: en-US
Connection: close
WCG基本上是在说,“你没有CORS吗?”或者我是否有更好的方法从客户端获取数据?我宁愿不必通过我的网络服务器获取/存储/代理这些数据。
我也希望有人可以使用WCG API链接到更好的文档或示例。信息似乎很少。
谢谢!