0

I'm trying to create a script that takes a path of a text file then goes through each line and sends a request then return the status code of the response and i'm trying to implement threads but the problem is that 50 threads for example sends 50 requests to each line not 50 requests to 50 different lines so how can i implement that?

import requests
import os
import threading
import sys


threads = []


def checkalive():
    txt_file = open("%s" % (sys.argv[1]), "r")

    headers = {
        'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0',
        }

    for line in file:
        requests.get("https://%s/" % (line), headers=headers)

for i in range(50):
    t = threading.Thread(target=checkalive)
    threads.append(t)
    t.start()
nijm
  • 2,158
  • 12
  • 28

0 Answers0