if __name__ == "__main__": import time start_time = time.time() # pip install threadpool import threadpool pool = threadpool.ThreadPool(10) urllist = [] for i in range(2,20): url = "xxx/?page={}/".format(i) urllist.append(url)
requests = threadpool.makeRequests(get_url,urllist) [pool.putRequest(req) for req in requests] pool.wait()
# for url in range(2,5): # url = "xxx/?page={}/".format(url) # get_url(url) print(time.time()-start_time)