I've been working on a program that would let you sign in to different web-pages and tells you if the sign in has been successfull. It Works by 1.Login into an account you know exists and is correct and copying the response text to a file, 2.Loging into an account that you know doesn't work and doing the same thing. Then, when you try to login to that web page the program Will compare the responses to the previously saved responses and finds similarities. If it finds more similarity's with the correct login text, this means it succeeded, if not it didn't. But this doesn't seem to work and I can't figure out why. I think it is because of the mechanism used to compare the responses, but I'm not sure. I'll leave the code here. Thanks for any answers!
import requests
def checkStatus(response): #we check if the response let us login by comparing it to previous responses. This algorythm should be able to work for every webpage
check1 = 0
check2 = 0
file1 = open("wronglogin.txt", "r")
file2 = open("correctlogin.txt", "r")
i = 0
for line in response:
try:
if file2.read(i) == line:
check2 += 1
i+=1
except:
break
i = 0
for line in response:
try:
if file1.read(i) == line:
check1 += 1
i+=1
except:
break
print(check1)
print(check2)
if check1 < check2:
return True
else:
return False
url = "https://twitter.com/explore"
username = "your_username"
headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36'}
password = "your_password"
form_data = { "username":str(username), "password":str(password) }
s = requests.Session()
response = s.post(url, headers = headers, data = form_data)
print(response.text)
if checkStatus(response.text) == True:
print(form_data["password"])