-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reorder speedtest servers URLs, preferring c.speedtest.net domain #765
base: devel
Are you sure you want to change the base?
Conversation
Hi guys. Is it possible now to get a list of servers of a specific country, for example USA when I'm using speed-test cli from Ukraine. It could be very useful feature. Now I have a choice to see servers of Ukraine's only |
I couldn't use any of my local servers by passing in their ids into get_servers(). I always got a no matched servers error. I noticed that the list I was pulling from was giving my local servers and speedtest-cli was not. Thankfully I stumbled upon this PR that fixes this exact problem. I checked out this branch (thanks @bprodoehl !) and it works great. I can use any of my local servers now. Hope this will be merged to the main package soon. |
By analyzing the official test webpage requests it seems JSON server list at https://www.speedtest.net/api/js/servers?engine=js&limit=10&https_functional=true is used instead of XML at www.speedtest.net/speedtest-servers(-static)?.php and c.speedtest.net/speedtest-servers(-static)?.php. |
I followed @mavoga hint and replaced the XML lists by the JSON list: It works fine and returns a better server list (the old one wouldn't return any server from my city, despite having a couple). However, I see download/upload results that are too far from the expected results, and from what I can see on the website. |
Hi @Kerybas , now it works like a charm here in Rome and the outcome is just as expected both for the servers used and for the speed test results. Thanks! |
@mavoga : re the number of servers, I notice that the API limits it at 20 but I forgot to change it in the code. :) |
Yes, basically. The current Speedtest.net web interface users a JSON-based endpoint to list the available servers: https://www.speedtest.net/api/js/servers. This one can take a
Adapting |
Hi All, I'm using to install:
and, but my server list still using XML instead of JSON, need i to wait a official release? or change the url of my command installation to use another reppository? Thanks! |
I've also noticed that https://www.speedtest.net/speedtest-servers-static.php returns much less accurate results if you send the request with a user agent that looks like a script. The difference can be observed when running these two commands: # Less accurate
curl 'https://www.speedtest.net/speedtest-servers-static.php' -H 'User-Agent: curl'
# More accurate
curl 'https://www.speedtest.net/speedtest-servers-static.php' -H 'User-Agent: kurl' This same difference is evident in |
Hi , |
Same issue here. I'm located in Switzerland but only get servers from France and Germany. If I change the order of the list of URL, it then works as expected, giving me servers in my country: --- speedtest.py 2022-04-07 10:43:41.620741209 +0200
+++ speedtest.py 2022-04-07 10:59:18.743962835 +0200
@@ -1250,10 +1250,10 @@
)
urls = [
- '://www.speedtest.net/speedtest-servers-static.php',
- 'http://c.speedtest.net/speedtest-servers-static.php',
'://www.speedtest.net/speedtest-servers.php',
'http://c.speedtest.net/speedtest-servers.php',
+ '://www.speedtest.net/speedtest-servers-static.php',
+ 'http://c.speedtest.net/speedtest-servers-static.php',
]
headers = {} |
There's a subtle difference in behavior between the c.speedtest.net and www.speedtest.net domains, with c.speedtest.net yielding a server list that is more relevant to the actual location that it is run from. This PR just reorders the four URLs that are used to fetch the server list, bumping the c.speedtest.net URLs to the top.
Both domains return 100 servers in the results, but if run from Perth, Australia, c.speedtest.net returns 100 servers centered around Perth (with 14 actually in Perth) and www.speedtest.net returns 100 servers centered around Sydney, with the nearest server over 1300 miles away. I have seen similar results in the US, as well.