Created
October 28, 2020 22:22
-
-
Save alejamp/f569778cf1ae1f9732b0193a72e3236a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from multiprocessing import Pool | |
import requests | |
import json | |
from random import randrange | |
def get_data(url): | |
response = requests.get(url) | |
print("Perform request to {} response: {}".format(url, response.status_code)) | |
print("elapsed time: {}".format(response.elapsed.total_seconds())) | |
return response.status_code | |
def request(url): | |
return get_data(url) | |
def get_request_list(url = "http://www.saij.gob.ar/resultados.jsp?o=50&p=2000"): | |
res = [] | |
for i in range(300000): | |
base_url = url | |
res.append(base_url) | |
return res | |
if __name__ == "__main__": | |
with Pool(100) as p: | |
print(p.map(request, get_request_list())) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment