Last active
April 10, 2017 22:35
-
-
Save Sam-Jenkins/bad6c48cd80274e79adedd0f0e066004 to your computer and use it in GitHub Desktop.
Send internet speeds to RapidSpike Connect Anything
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import subprocess | |
import json | |
import urllib2 | |
speedtest = json.loads(subprocess.check_output(['speedtest-cli', '--json'])) | |
req = urllib2.Request( | |
'https://results.rapidspike.com/rca/', | |
json.dumps( | |
{ | |
'id':'ex4mp13-ex4mp13-ex4mp13-ex4mp13', | |
'down':round(speedtest['download']/1048576,2), | |
'up':round(speedtest['upload']/1048576,2), | |
'ping':round(speedtest['ping'],3), | |
'latency':round(speedtest['server']['latency'],3) | |
} | |
) | |
) | |
response = urllib2.urlopen(req) | |
print response.read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment