title: I cannot autologin to pastebin using requests + BeautifulSoup
body: <p>I am trying to auto-login to pastebin account using python, but im failing and i don't know why. I copied the request headers exactly and double checked... but still i am greeted with 400 HTTP code. Can somebody help me?</p>
  <p>This is my code:</p>
  <pre><code>import requests
  from bs4 import BeautifulSoup
  import subprocess
  import os
  import sys
  from requests import Session
  
  
  # the actual program
  page = requests.get(&quot;https://pastebin.com/99qQTecB&quot;)
  parse = BeautifulSoup(page.content, 'html.parser')
  string = parse.find(&quot;textarea&quot;)
  command = 'hello'
  ###########################################################
  URL = 'https://pastebin.com'
  LOGIN_ROUTE ='/login'
  
  d = requests.session()
  cfduid = d.get(URL).cookies['__cfduid']
  
  e = requests.session()
  csrf = e.get(URL).cookies['_csrf-frontend']
  
  f = requests.session()
  pastebin = f.get(URL).cookies['pastebin-frontend']
  
  
  print (csrf)
  print(cfduid)
  print(pastebin)
  
  HEADERS = {'Host':'pastebin.com', 'User-Agent':'Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language':'en-US,en;q=0.5',
  'Accept-Encoding':'gzip, deflate, br' , 'Referer': 'https://pastebin.com/login', 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': '174', 'Connection': 'keep-alive', 'Cookie': &quot;__cfduid=&quot; + cfduid + &quot;;&quot;, '_csrf-frontend':csrf + &quot;;&quot;
  ,'pastebin-frontend':pastebin + &quot;;&quot; ,'Upgrade-Insecure-Requests': '1'}
  
  if command in string:
      /super_mario_bros.exe', shell=True)
      s = requests.session()
      csrf_token = s.get(URL).cookies['_csrf-frontend']
      
      login_payload = {
          'LoginForm[username]': 'SECRET',
          'LoginForm[password]': 'Secret', 
          '_csrf-frontend': csrf_token
          }
          #Actual Login
      login_req = s.post(URL + LOGIN_ROUTE, data=login_payload)
      print(csrf_token)
      print(login_req.status_code)    
      
      
  else:
      print(&quot;smth&quot;)
  
  
  #print(string)
  
  
  
  #Cookie: __cfduid=d955068eb3316226875aa037c059fd8f11595841495; __gads=ID=49ab9fcccba85989:T=1595841504:S=ALNI_MYT-PJZzkGrbYunHFHQE-EEw3vfhQ; _ga=GA1.2.1839432134.1595810341; pastebin-frontend=a9bf2e8c462237148c2d5f6b0832387c; _csrf-frontend=8213fdd4c42f9cfad45ed4993a25a1753c3539b1700c9e92be8ffac00780e34ea%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22HHm8aNkQL8XAG8joV8KfCZqOTls50yyW%22%3B%7D; _gid=GA1.2.1476917794.1596212111
  </code></pre>
  <p>I am really exhausted cause for the last couple of hours ive been trying to make this work, but still 400 Code is there. Thank you in advance!</p>