当出现错误时,它会在 Python 上重试相同的用户名

我的代码:


import requests

from time import sleep

from colorama import Fore


file = [line.rstrip('\n') for line in open('myusername.txt')]

count = 0


URL = "https://127.0.0.1/ajax/attempt/"

headers = {

    'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'}


for username in file:

    count += 1

    data = {

        'firstname':'firstname',

        'lastname' : 'lastname',

        'username': username

    }

    r = requests.post(url = URL, headers=headers, data = data)

    responde = r.text

    print(responde)

    if ('error_type' in responde):

        print('{}[+]Trying ({}/{}) -{}{} Username: {} Taken{}'.format(Fore.WHITE, count, len(file), Fore.RESET, Fore.RED, username, Fore.RESET))

    elif ('account_valid' in responde):

        print('{}[+]Trying ({}/{}) -{}{} Username: {} Available{}'.format(Fore.WHITE, count, len(file), Fore.RESET, Fore.GREEN, username, Fore.RESET))

    elif ('Please wait a few minutes before you try again.' in responde):

        sleep(30)

        print('{}[+]Waiting 30Sec for recheck ...{}'.format(Fore.YELLOW, Fore.RESET))

当我的程序看到responde Please wait a few minutes before you try again它时,等待 30 秒并重试。


但问题是,它会在服务器繁忙时绕过该用户名,并为下一个用户尝试。


我希望在等待后出现服务器忙时,使用同一用户重试并继续..


白猪掌柜的
浏览 183回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python