0

The code doesn't work, and I cannot figure out why. I found the input values using FireFox developer inspector. password is of type password, pwdtext is a text, but only password is connected to the input field. Submit is called login and its content is Log In. Still I cannot logging, and I cannot figure out what I'm doing wrong.
Cookies is always empty. I believe that I have type missmatch, or I'm missing additional inputs.

login_data = {
 'username' : 'UserName',
 'password' : "Password", #This a password type in the html
 'pwdtext'  :'Password',  #This has no value and no html widget connected to
 'login'    : "Log In"


}
headers = {'User-agent':
  'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7)'}
with requests.session() as c:
      request = c.post('http://share.food.com/registration/login.esi',    data=login_data,headers=headers)
      print(request.url)
      print(request.cookies)
      request = c.get('http://www.food.com/recipe-finder/all/shrimp?pn=25')
      print (request.cookies)

1 Answers1

0

Looking at the login page, the actual login data dictionary should look like

{
    'username': 'your_email@address.com',
    'password': 'your_secret_password',
    'pwdtext': 'your_secret_password',
    'login': 'Log In',
    'SMSAVECREDS': 'YES'
}

That last item is another hidden input in the form that you likely missed.

If that doesn't work, I would advise doing

c.get('http://share.food.com/registration/login.esi')

First so that any cookies that are set before login are present when you make the post request.

Ian Stapleton Cordasco
  • 26,944
  • 4
  • 67
  • 72