title: Send CSRF token to a form using request
body: <p>I'm using the request library to log in to a page that contains the following form:</p>
  
  <pre><code>&lt;form action="login.php" method="post" id="login"&gt;
          &lt;input type="hidden" name="__CSRFToken__" value="022d7665c7dc20683af1a66680560500f9ad4770" /&gt;        &lt;input type="hidden" name="do" value="scplogin"&gt;
          &lt;fieldset&gt;
          &lt;input type="text" name="userid" id="name" value="" placeholder="E-mail ou Usuário"
              autofocus autocorrect="off" autocapitalize="off"&gt;
          &lt;input type="password" name="passwd" id="pass" placeholder="Senha" autocorrect="off" autocapitalize="off"&gt;
                          &lt;button class="submit button pull-right" type="submit" name="submit"&gt;&lt;i class="icon-signin"&gt;&lt;/i&gt;Login&lt;/button&gt;
          &lt;/fieldset&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>I used the following code but I did not succeed</p>
  
  <pre><code>Import requests
  from bs4 import BeautifulSoup
  
  session = requests.Session()
  
  
  
  url = "https://page.with.form/scp/login.php"
  
  
  # Retrieve the CSRF token first
  soup = BeautifulSoup(client.get(url).content)
  csrftoken = soup.find('input', dict(name='__CSRFToken__'))['value']
  print(csrftoken)
  
  params = {'__CSRFToken__': csrftoken, 'do': 'scplogin', 'passwd':'password', 'submit':'', 'userid':'username'}
  
  s = session.post(url,params)
  print("Cookie is set to:")
  print(s.cookies.get_dict())
  print("----------------")
  
  print(s.text)
  </code></pre>
  
  <p>Can someone help me? Thank you</p>