Python Forum

Full Version: Requests problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,
I'm trying to connect to a website with requests library.
This is my code :

import requests

url = 'http://www.website.com'

values = {
    'loginForm': 'loginForm',
    'loginForm:login': '',
    'loginForm:password': '',
    'loginForm:submit': 'Valider',
    'javax.faces.ViewState': 'j_id2'
}

with requests.Session() as s:
    response = s.post(url, data=values)
    print(response.text)
When i'm executing this one, it will redirect me at the same page, login form. I don't know why.
Did I forgot something ?

Here are informations I sent when I submit form.

[Image: 180522100614516744.png]

Thanks for your help Sad
It deepens on what login needs,it can vary on different web-sites.
Now you only send form values,it may need some header data and maybe also Cookies.
Look at this post there did i inspect the web-site.
He respond was that it did work.
On safe forms you have a hidden variable, which should be sent together with the post request.
(May-22-2018, 11:12 AM)snippsat Wrote: [ -> ]It deepens on what login needs,it can vary on different web-sites.
Now you only send form values,it may need some header data and maybe also Cookies.
Look at this post there did i inspect the web-site.
He respond was that it did work.

It works sorry for the duplicate.
Thank you for your help ! ;)