MENU

URL批量测速及最优速度

June 15, 2021 • 折腾阅读设置

#Save these codes and rename example.py.
#found url.txt in the same menu like example.py.
#input your urls in url.txt with line feed.
import requests
import os
#import functools
#import time
def spend(web):
    r = requests.get(web)
    return r.elapsed.total_seconds()

with open('url.txt','r')as f:
    url=f.read().splitlines()
    sudu=list(map(spend,url))
    zidian=dict(zip(url,sudu))
    sort=sorted(zidian.items(),key=lambda e:e[1]) 
    for a,b in sort:
        print(a," 的响应时间为 ",b,"秒")
Last Modified: July 3, 2021
Archives QR Code Tip
QR Code for this page
Tipping QR Code