如何使这个python脚本连续/反复运行
今天有人试图通过网络钓鱼网站窃取我的登录信息。 所以我决定用随机的电子邮件和密码来发送垃圾邮件,我找到了一段代码,它似乎可以工作。我唯一的问题是,我不能让程序反复运行。如果我运行该程序,只会发送一封电子邮件/密码,然后程序结束。也许我使用了错误的python版本?我在“Python3.8.1”上,这段代码是在2018年编写的。代码如下:如何使这个python脚本连续/反复运行,python,python-3.x,Python,Python 3.x,今天有人试图通过网络钓鱼网站窃取我的登录信息。 所以我决定用随机的电子邮件和密码来发送垃圾邮件,我找到了一段代码,它似乎可以工作。我唯一的问题是,我不能让程序反复运行。如果我运行该程序,只会发送一封电子邮件/密码,然后程序结束。也许我使用了错误的python版本?我在“Python3.8.1”上,这段代码是在2018年编写的。代码如下: import os import random import string import json chars = string.ascii_letters
import os
import random
import string
import json
chars = string.ascii_letters + string.digits + '!@#$%^&*()'
random.seed = (os.urandom(1024))
url = 'http://domainname/index.php'
names = json.loads(open('names.json').read())
for name in names:
name_extra = ''.join(random.choice(string.digits))
username = name.lower() + name_extra + '@yahoo.com'
password = ''.join(random.choice(chars) for i in range(8))
requests.post(url, allow_redirects=False, data={
'email': username,
'pass': password
})
print ('sending username %s and password %s' % (username, password))
names.json是一个带有随机名称的json。尝试将代码放入
while True
循环中,如果您真的想确定它是否会连续运行,您也应该将其放入Try except
块中
试着这样做:
while True:
try:
#your current code
#(not including the import statements and the deceleration of the chars and url variables)
except Exception as error:
print(error)
刚刚尝试过,但我无法通过“预期为缩进块”错误..:(