循环一个简短的python脚本,用于解析json文件中的数据

循环一个简短的python脚本,用于解析json文件中的数据,python,json,python-3.x,parsing,python-requests,Python,Json,Python 3.x,Parsing,Python Requests,我希望标题有意义,英语不是我的第一语言,我不知道我是否写对了。。 基本上,我有一个用于钓鱼网站的python脚本,用随机数据对其进行垃圾邮件处理。 我有.py文件和.json文件 app.py: import requests import os import random import string import json chars = string.ascii_letters + string.digits + '!@#$%^&*()' random.seed = (os.ura

我希望标题有意义,英语不是我的第一语言,我不知道我是否写对了。。 基本上,我有一个用于钓鱼网站的python脚本,用随机数据对其进行垃圾邮件处理。 我有.py文件和.json文件

app.py:

import requests
import os
import random
import string
import json

chars = string.ascii_letters + string.digits + '!@#$%^&*()'
random.seed = (os.urandom(1024))

url = 'site/file.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(12))

    requests.post(url, allow_redirects=False, data={
        'login': username,
        'pass': password
    })

    print ('sending username %s and password %s' % (username, password))
json有两个随机名称:

[
"Liam",
"Noah",
"William"
]
在my names.json中,我有大约40个随机名称,每次启动程序时,它都会遍历所有40个名称,然后它就会关闭。。
我有没有办法无限循环地浏览这些名字?并让程序全天候运行?

如果您真的希望它永远运行(或直到结束),您可以使用

while(True):
    print("This will go forever")
目前还不清楚您希望永远运行哪个部分,但在您的情况下,这看起来像

while(True):
    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(12))

        requests.post(url, allow_redirects=False, data={
            'login': username,
            'pass': password
        })

        print ('sending username %s and password %s' % (username, password))