python - 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()
解决方案
对不起,我还不能发表评论,所以我必须把它写成答案。怎么去掉try/except
方块?特别是内部捕获所有异常,因此您不会收到任何错误报告。(通常一个很好的建议是始终指定您想要捕获的异常)
推荐阅读
- excel - 如何找到工作表中存在的所有值?
- pandas - 在 jupyterlab 中的 pandas df 中呈现超链接
- java - 如何将 JSON 消息转换为具有可为空字段的 avro 模式的有效 JSON?
- stored-procedures - 在我的 MySQL 存储过程中使用事务和更新查询如何确保更新完成
- hibernate - 如何使用 spring-data-jpa 和复合键保存多对多关系
- java - 如何计算肯定会在某个点结束的无限循环的时间复杂度?
- node.js - 如何从这些输入中获取数据
- prestashop - 如何修复 ContextErrorException:警告:声明
- c# - C# 引用指针
- python - 如何在 CodeHS 8.4.12:图书馆员,第 2 部分中仅打印姓氏?