forked from railbotan/multi-task-at-19
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIOBound.py
More file actions
24 lines (22 loc) · 845 Bytes
/
IOBound.py
File metadata and controls
24 lines (22 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from urllib.request import Request, urlopen
from urllib.parse import unquote
from urllib.request import urlopen
from urllib.parse import unquote
from bs4 import BeautifulSoup
from tqdm import tqdm
import concurrent.futures
if __name__ == "__main__":
links = open('res.txt', encoding='utf8').read().split('\n')
with concurrent.futures.ThreadPoolExecutor(max_workers=100) as executor:
for url in links:
try:
request = Request(
url,
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(url, e)