title: How to login with python requests: a tricky case
body: <p>I am trying to access to a website provided by my school, in order to automate the process of checking if a something has been published (such as marks, news, etc.).</p>
  
  <p>I analized the page's html code and searched for all the input tags (even hidden tags) and put them in a dictionary. I wrote this code:</p>
  
  <pre><code>import requests, lxml.html
  from bs4 import BeautifulSoup as bs
  
  login_url = "https://www.portaleargo.it/argoweb/famiglia/common/login_form2.jsp"
  whenloggedin_url = "https://www.portaleargo.it/argoweb/famiglia/index.jsf#"
  
  def try_conn(sch_code, user, password):
  
  with requests.Session() as s:
  
      headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36'}
      site = s.get(login_url, headers = headers)
      bs_content = bs(site.content, "html.parser")
      token = bs_content.find("input", {"id":"cod_utente"})["value"]
      login_data = {
          "codice_scuola":sch_code,
          "utente":user,
          "j_password":password,
          "cod_utente":token,
      }
  
      login = s.post(login_url, data = login_data)
  
      #Proof that it logged in correctly
  
      if login.url == whenloggedin_url:
  
          return True
  
      return False
  </code></pre>
  
  <p>The function returns False. I also tried to print login.status_code (and it returns 200). I really cannot say why this is not working. What should I do?</p>