0

So I am trying to write a script that that submits a form that contains two fields for a username and password in a POST request, but the site responds with:

"This system requires the use of HTTP cookies to verify authorization information. Our system has detected that your browser has disabled HTTP cookies, or does not support them."

*EDIT: So I believe with the new modified code below that I can successfully login to the page. The only thing is that when I print out the page's html text to the terminal it only displays an html element and a head element that contains the url of the page; however, ive inspected the actual html of page when i log in and there is a lot missing, anyone know why this might be?

import requests

url = "https://someurl"

payload = {
    'username': 'myname',
'password': '1234'
}

headers = {
'User-Agent': 'Mozilla/5.0'
}

session = requests.Session()

page = session.post(url, data=payload)
user1999073
  • 106
  • 1
  • 6
  • possible duplicate of [How to use Python to login to a webpage and retrieve cookies for later usage?](http://stackoverflow.com/questions/189555/how-to-use-python-to-login-to-a-webpage-and-retrieve-cookies-for-later-usage) – Steinar Lima Apr 12 '14 at 04:07

1 Answers1

0

Without the precise URL it is very hard to give you an answer. Many Web pages are dynamically built through JavaScript calls. The execution of the JavaScript will create a DOM that is rendered. If it's the case for the site you are looking at, you will get only the raw HTML response with Python but not the rendered DOM. You need something which actually executes the JS to get the final DOM. For example, SlimerJS

karlcow
  • 6,977
  • 4
  • 38
  • 72