0
1

Pythonでスピードテスト作ってみた

Last updated at Posted at 2024-02-20

こんにちはKです。

今回はいつもスピードテストのサイトに行って回線チェックを行うのですがPythonでチェックできないかなと思い調べると簡単に見つかったので紹介します。

pip speedtest-cli

Python
    import speedtest 
    
    st = speedtest.Speedtest()
    st.get_best_server()
    
    # 速度測定を実行
    download_speed = st.download() / 1024 / 1024  # Mbpsに変換
    upload_speed = st.upload() / 1024 / 1024  # Mbpsに変換
    ping = st.results.ping
    
    print("[測定結果]")
    print(f"download_speed: {download_speed}Mbps")
    print(f"upload_speed: {upload_speed}Mbps")
    print(f"ping: {ping}ms")

これだけです。
これで毎朝自分にメールで回線チェックができるようになりました。
めでたしめでたし

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1