Это мой код
Код: Выделить всё
import requests
import multiprocessing
import time
start_time = time.time()
def one():
global start_time
for n in range(1000, 4000):
answer = requests.post('https://www.guessthepin.com/prg.php', data={'guess': n})
if "Holy Moley!" not in str(answer.text):
print("The pin is not", n)
continue
print(f"THE PIN IS: {n}")
end_time = time.time()
print(f"Time taken: {(end_time - start_time) / 60} minutes")
sys.exit()
def two():
global start_time
for n in range(4000, 7000):
answer = requests.post('https://www.guessthepin.com/prg.php', data={'guess': n})
if "Holy Moley!" not in str(answer.text):
print("The pin is not", n)
continue
print(f"THE PIN IS: {n}")
end_time = time.time()
print(f"Time taken: {(end_time - start_time) / 60} minutes")
sys.exit()
def three():
global start_time
for n in range(7000, 10000):
answer = requests.post('https://www.guessthepin.com/prg.php', data={'guess': n})
if "Holy Moley!" not in str(answer.text):
print("The pin is not", n)
continue
print(f"THE PIN IS: {n}")
end_time = time.time()
print(f"Time taken: {(end_time - start_time) / 60} minutes")
sys.exit()
def four():
global start_time
for n in range(0, 1000):
zero_thousand = f'{n:04}'
request = requests.post('https://www.guessthepin.com/prg.php', data={'guess': zero_thousand})
if "Holy Moley!" not in str(request.text):
print("The pin is not", zero_thousand)
continue
print(f"THE PIN IS: {n}")
end_time = time.time()
print(f"Time taken: {(end_time - start_time) / 60} minutes")
sys.exit()
if __name__ == "__main__":
start_time = time.time()
p1 = multiprocessing.Process(target=one)
p2 = multiprocessing.Process(target=two)
p3 = multiprocessing.Process(target=three)
p4 = multiprocessing.Process(target=four)
p1.start()
p2.start()
p3.start()
p4.start()
p1.join()
p2.join()
p3.join()
p4.join()
print("Done!")
end_time = time.time()
print(f"Time taken: {(end_time - start_time)/60} minutes")
Подробнее здесь: https://stackoverflow.com/questions/786 ... -in-python