forked from bibilov/multi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync.py
More file actions
22 lines (20 loc) · 863 Bytes
/
sync.py
File metadata and controls
22 lines (20 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import time
from urllib.request import Request, urlopen
start_time = time.time()
with open('res.txt', "r", encoding='utf8') as f:
links_array = f.readlines()
for link in links_array:
try:
request = Request(
link,
headers={'User-Agent': 'Mozilla/5.0 (Windows NT 9.0; Win65; x64; rv:97.0) Gecko/20105107 Firefox/92.0'},
)
resp = urlopen(request, timeout=5)
code = resp.code
print(code)
resp.close()
except Exception as e:
print(link, e)
end_time = time.time()
print(f"Время выполнения программы при синхронном выполнении {end_time - start_time}")
#Время выполнения программы при синхронном выполнении 6.117567300796509 (делал на 10 ссылках)