у меня Python 3 Windows 7
Этот код перебирает из файла список прокси и чекает их по заголовку,
работает как нужно только скорости маловато..
помогите пожалуйта добавить в этот код многопоточность (хоть на 10 потоков)
очень нужно!
import requests headers = { 'Connection':'keep-alive', 'User-Agent':'DuneHD/1.0.3 SmartLabs Smartsdk Smart TV/Apple TV Linux', 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Encoding':'gzip, deflate, lzma, sdch', 'Accept-Language':'ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4', 'Upgrade-Insecure-Requests':'1', 'DNT':'1', } with open ("Out.txt","a") as f: error = '' for line in open('IPs.txt'): try: line = line.strip() req = requests.get(line,headers=headers,timeout=(2,2)) status = req.status_code server = req.headers.get('Server','') f.write(' '.join([server,line,'\n'])) except requests.exceptions.RequestException as err: status = '' error = err finally: print('{:30}:{:3}:{}'.format(line,status,error or server))
Вот текст (Proxy) с файла IPs.txt
http://31.148.103.65:81
http://93.125.53.105:8086
http://82.209.197.187:8080
http://178.151.158.252:8080
http://37.194.224.203:81
http://188.35.9.26:2051
http://31.148.16.31:8080
http://185.23.64.14:8080
http://87.145.189.129:9981
