diff --git a/README.rst b/README.rst index 0043b5c..0639e2e 100644 --- a/README.rst +++ b/README.rst @@ -71,6 +71,21 @@ or Usage ----- +You can use in another script via the following: + +:: + + DownloadParsed = re.compile(r"Download: ([\d.]+) .bit") + UploadParsed = re.compile(r"Upload: ([\d.]+) .bit") + PingParsed = re.compile(r"([\d.]+) ms") + speedtest_result = str(subprocess.check_output(['speedtest-cli'], stderr=subprocess.STDOUT)) + download = DownloadParsed.search(speedtest_result).group(1) + upload = UploadParsed.search(speedtest_result).group(1) + ping = PingParsed.search(speedtest_result).group(1) + print("Download Speed: " + download + " mbps\n" + "Upload Speed: " + upload + " mbps\n" + "Ping: " + ping + " ms") + +You can use in terminal via the following: + :: $ speedtest-cli -h