speedtest.net api

匿名 (未验证) 提交于 2019-12-03 03:05:02

问题:

I want to make a widget to display the user's most recent speed test results. Does speedtest.net have an api I could use? I tried making an ajax request to http://speedtest.net/csv.php?csv=1&ria=0&s=0 but got a cross domain error. I tried an iframe, but that just made it appear in downloads.

This is going to be in a Google Chrome extension so I can use the chrome api if necessary.

回答1:

speedtest.net is run by Ookla and their Speed Test application. Unfortunately they don't provide any public APIs for speedtest.net which you could use.

Although I doubt either of these meet your needs, they do provide Speed Test Mini and a hosted reporting solution for their full Speed Test software package (which includes CSV exporting capabilities).

The reason you're unable to use AJAX is because Chrome will not allow JavaScript to perform cross-site requests unless the Access-Control-Allow-Origin response header is set in the response from speedtest.net to permit such a request.

In a Chrome extension, however, you can allow cross-origin requests by adding the URL to the permissions section of your manifest.json file. For example:

"permissions": [   "http://*/" ], 

You could then use a bit of jQuery to retrieve the CSV data as a string (see this answer):

$.get('http://speedtest.net/csv.php?csv=1&ria=0&s=0', function(data) {     var csv = new String(data);     // do stuff with csv }, dataType='text'); 


回答2:

You can make cross-origin XMLHttpRequests in a chrome extension, provided that you've requested permissions for it.

In your manifest.json file, add the URI:

"permissions": ["http://speedtest.net/csv.php?*"] 

See also: Match patterns.



回答3:

Try MySpeed.today. It may work out.



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