title: check if login was correct with python requests
body: <p>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!</p>
  <pre><code>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(&quot;wronglogin.txt&quot;, &quot;r&quot;)
      file2 = open(&quot;correctlogin.txt&quot;, &quot;r&quot;)
  
      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 &lt; check2:
          return True
      else:
          return False
  
  url = &quot;https://twitter.com/explore&quot;
  username = &quot;your_username&quot;
  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 = &quot;your_password&quot;
  form_data = { &quot;username&quot;:str(username), &quot;password&quot;: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[&quot;password&quot;])
  
  </code></pre>