Login to https website using Python
<p>I'm new to posting on stackoverflow so please don't bite! I had to resort to making an account and asking for help to avoid banging my head on the table any longer...</p>

<p>I'm trying to login to the following website <a href="https://account.socialbakers.com/login" rel="nofollow">https://account.socialbakers.com/login</a> using the requests module in python. It seems as if the requests module is the place to go but the session.post() function isn't working for me. I can't tell if there is something unique about this type of form or the fact the website is https://</p>

<p>The login form is the following:</p>

<pre><code>&lt;form action="/login" id="login-form" method="post" novalidate=""&gt;
        &lt;big class="error-message"&gt;
         &lt;big&gt;
          &lt;strong&gt;
          &lt;/strong&gt;
         &lt;/big&gt;
        &lt;/big&gt;
        &lt;div class="item-full"&gt;
         &lt;label for=""&gt;
          &lt;span class="label-header"&gt;
           &lt;span&gt;
            Your e-mail address
           &lt;/span&gt;
          &lt;/span&gt;
          &lt;input id="email" name="email" type="email"/&gt;
         &lt;/label&gt;
        &lt;/div&gt;
        &lt;div class="item-list"&gt;
         &lt;div class="item-big"&gt;
          &lt;label for=""&gt;
           &lt;span class="label-header"&gt;
            &lt;span&gt;
             Password
            &lt;/span&gt;
           &lt;/span&gt;
           &lt;input id="password" name="password" type="password"/&gt;
          &lt;/label&gt;
         &lt;/div&gt;
         &lt;div class="item-small"&gt;
          &lt;button class="btn btn-green" type="submit"&gt;
           Login
          &lt;/button&gt;
         &lt;/div&gt;
        &lt;/div&gt;
        &lt;p&gt;
         &lt;a href="/email/reset-password"&gt;
          &lt;strong&gt;
           Lost password?
          &lt;/strong&gt;
         &lt;/a&gt;
        &lt;/p&gt;
       &lt;/form&gt;
</code></pre>

<p>Based on the following post <a href="http://stackoverflow.com/questions/11892729/how-to-log-in-to-a-website-using-pythons-requests-module">How to &quot;log in&quot; to a website using Python&#39;s Requests module?</a> among others I have tried the following code:</p>

<pre><code>url = 'https://account.socialbakers.com/login'
payload = dict(email = 'Myemail', password = 'Mypass')
with session() as s:
    soup = BeautifulSoup(s.get(url).content,'lxml')
    p = s.post(url, data = payload, verify=True)
    print(p.text)
</code></pre>

<p>This however just gives me the login page again and doesn't seem to log me in</p>

<p>I have checked in the form that I am referring to the correct names of the inputs 'email' and 'password'. I've tried explicitly passing through cookies as well. The verify=True parameter was suggested as a way to deal with the fact the website is https.</p>

<p>I can't work out what isn't working/what is different about this form to the one on the linked post.</p>

<p>Thanks</p>

<p>Edit: Updated p = s.get to p = s.post</p>

<p>Two things to look out. One, try to use s.post and second you need to check in the browser if there is any other value the form is sending by looking at the network tab. </p>

python python-requests