So I have a program that checks proxies from a list however it's very slow so I added multiprocessing. But my problem is when I run the program it reads only the first line from the text file but when I run the code without multiprocessing it reads down the lines in the file. IDK I think it's something to do with {proxies = file.readline()}
.
import requests
from lxml.html import fromstring
import time
import multiprocessing
from multiprocessing import Pool
#kind = input("socks4, socks5, http/https:\n")
kind = 'socks4'
checking = True
file = open("SOCKS4.txt",'r')
def check():
proxies = file.readline()
proxys = {'http': kind + '://' + proxies, 'https': kind + '://' + proxies}
url = ('http://checkip.dyndns.com/')
try:
response = requests.get(url, timeout = 2.5, proxies = proxys)
except requests.exceptions.Timeout:
print('Bad', proxies)
except requests.exceptions.ConnectionError:
print('Network problem', proxies)
else:
print('Good', proxies, 'Response time', response.elapsed)
files = open('goods.txt', 'a+')
files.write('\n' + proxies)
if __name__ == '__main__':
while checking:
p = multiprocessing.Process(target=check)
p.start()