首页 > 解决方案 > Python 脚本不起作用,但没有提供任何帮助的错误消息

问题描述

一般来说,我是编程/脚本的新手,刚刚开始了解 python3.8 的基本工作原理。无论如何,我在这里有一个我一直在研究的脚本,用于随机生成 Instagram 帐户生成器。

如果这似乎是一个愚蠢的问题,请原谅,但毕竟我是新手:(。当我运行上面的脚本时,我没有收到任何输出以及没有错误消息,导致我不知道我到底做错了什么!

import random
import string
from threading import Thread
from discord_webhook import DiscordWebhook
from discord_webhook import DiscordWebhook, DiscordEmbed


webhookbro = "webhook"#Discord WebHook
password = "MadeWithLoveByOnurCreed"
threads_ammount = 50

max_proxies = 0
proxies = [line for line in list(set(open("Proxies.txt", encoding="UTF-8",  errors="ignore").read().splitlines()))]
for x in proxies:
    max_proxies += 1
def run():
    global max_proxies
    while True:
      proxy = proxies[random.randint(0,max_proxies-1)]
      asd = ('').join(random.choices(string.ascii_letters + string.digits, k=10))
      with requests.Session() as (c):
        email = str(asd+"@gmail.com")
        password = "MadeWithLoveByOnurCreed"
        username = str("Jacob"+asd)
        name = str("Jacon"+"P")
        asd = random
        data = {
                'email': email,
                'password': password,
                'username': username,
                'first_name': name,
                'client_id': 'W6mHTAAEAAHsVu2N0wGEChTQpTfn',
                'seamless_login_enabled': '1',
                'gdpr_s': '%5B0%2C2%2C0%2Cnull%5D',
                'tos_version': 'eu',
                'opt_into_one_tap': 'false'
                    }
        headers = {
                'accept': "*/*",
                'accept-encoding': "gzip, deflate, br",
                'accept-language': "en-US,en;q=0.8",
                'content-length': "241",
                'content-type': 'application/x-www-form-urlencoded',
                'origin': "https://www.instagram.com",
                'referer': "https://www.instagram.com/",
                'user-agent': "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36",
                'x-csrftoken': "95RtiLDyX9J6AcVz9jtUIySbwf75WhvG",
                'x-instagram-ajax': "c7e210fa2eb7",
                'x-requested-with': "XMLHttpRequest",
                'Cache-Control': "no-cache"
                }
        try:
            req = c.post("https://www.instagram.com/accounts/web_create_ajax/",data=data,headers=headers,proxies={'https': 'https://' + proxy,'http':'http://' + proxy}).json()
            try:
                created = req['account_created']
                if created is True:
                    userid = req['user_id']
                    print(f"Successfully Created A Account | Username : {username} | Password : {password}")
                    webhook = DiscordWebhook(url=webhookurlbro, username="Testing")
                    embed = DiscordEmbed(title='Testing', color=242424)
                    embed.set_footer(text='Testing')
                    embed.set_timestamp()
                    embed.add_embed_field(name='Username', value=f'{username}')
                    embed.add_embed_field(name='Password', value=f'{password}')
                    embed.add_embed_field(name='Proxy', value=f'{proxy}')
                    webhook.add_embed(embed)
                    webhook.execute()
                    save = open("Accounts.txt","a")
                    save.write(f"{username}:{password}\n")
                else:
                  dk = None
            except:
                dk = None
        except requests.ConnectionError:
            dk = None
threads = []
for i in range(0,threads_ammount):
    threads.append(Thread(target=run))
for thread in threads:
    thread.start()
for thread in threads:
    thread.join()

标签: pythonpython-3.xinstagram

解决方案


对不起,我还不能发表评论,所以我必须把它写成答案。怎么去掉try/except方块?特别是内部捕获所有异常,因此您不会收到任何错误报告。(通常一个很好的建议是始终指定您想要捕获的异常)


推荐阅读