I would like to create a program that measures the communication speed to the Internet with python and saves it in a CSV file.
After investigating various things, I found out that there is a Speedtest-cli, for the time being,
When I copied and executed the code, I was able to execute it and measure the speed.
However, the content of the code, the function of this Speedtest-cli, or the method
It is in a state where it is completely impossible to grasp what kind of operation is performed and what kind of value is returned.
For example, what does speedtest.Speedtest () do and what value does it return?
How can I find the explanation (documentation) about speedtest and speedtest?
Even if I checked the following site, the module (library) called speedtest was not posted. .. ..
It is said that python has many useful modules (libraries),
It is not good to use it without knowing the contents, so each one
I would like to create it while understanding it.
Code that was copied and executed
import sys import speedtest def get_speed_test (): servers =  stest = speedtest.Speedtest () stest.get_servers (servers) stest.get_best_server () return stest def command_line_runner (): stest = get_speed_test () down_result = stest.download () up_result = stest.upload () mbps_down_result = down_result/1024/1024 mbps_up_result = up_result/1024/1024 result = [mbps_down_result, mbps_up_result] print (result) command_line_runner ()
Answer # 1
All the details of the operation are written in the source code.
It seems that I sent a request to the api endpoint of the speed measurement site http://www.speedtest.net/ and processed the obtained result.
How to use in python
It seems that it is written in
I wrote a brief explanation while looking at the contents of the following source.
(The command above is the explanation, and the comment below is the explanation)
import speedtest s = speedtest.Speedtest () #Create an object for speed measurement. servers =  # A list of server IDs. Specify in the argument of get_servers () function, # Specify the ID of the server used for measurement in the list. # You can refer to the specified server ID at https://www.speedtest.net/speedtest-servers-static.php. #Example: servers = [37950, 18709] threads = None # You can measure in parallel using the specified number of threads. # When measuring with a single thread, 1. If # None is specified, the value automatically set by speedtest.net will be set as the number of execution threads. s.get_servers (servers) Specifies the server ID described in the list specified in the # argument as the measurement server. s.get_best_server () Use #ping to specify the server with the lowest latency as the measurement server. s.download (threads = threads) #Measure download speed and return speed in bits/sec. The number of threads specified in threads will be used. s.upload (threads = threads) # Measures upload speed and returns speed in bits/sec. The number of threads specified in threads will be used. s.results.share () #Measurement result Generates a shared URL for the image.
- about excel operation of python
- about the python speedtest code
- python - about the follow-up operation of text update of pysimple gui
- i have a question about basic python problems
- python - about "" "of" "" select === = "" "
- python, about the fire spread step of forest fire simulation
- python - about hamiltonian neural networks
- python - about write loop to csv
- python 3x - i want to use python for responder's view operation
- python 3x - about downloading anaconda
- about python argument and data definition
- python - about the optimum angle of rotation matrix
- python - about downloading youtube videos by youtube-dl
- about processing to exclude the character string group specified from list in python
- python - what i don't understand about yolo9000 (v2)
- about batch change of file name using python
- about the implementation of combinations in python
- please tell me about the role of python tag = "mychr"
- python - about x-axis adjustment in matplotlib
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- python 3x - typeerror: 'method' object is not subscriptable
- i want to call a child component method from a parent in vuejs
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- xcode - pod install [!] no `podfile 'found in the project directory