You may have seen this already, but there is a Python utility that works with Speedtest.net called "speedtest-cli".
pip install speedtest-cli
https://github.com/sivel/speedtest-cli