Automatic login into specific site

Automatic login into specific site

Postby fefe78 » Fri May 17, 2013 7:56 am

Hi everybody,

I'm trying to do an easy access to a web site, already done with other sites behind POST authentication, but cannot succeed with this.
The site is dyn.com. My goal is to automate login once a month, because from a dyn.com mail announcement, they said if I don't log into site once a month, the account will expire.
I tried using the common urllib2 and cookielib and also with session object from requests package, but after posting data, it always reply me the authentication page again.
Don't know if is a problem with cookies or other tricky mechanism.

This is the site url for login : https://account.dyn.com/entrance
If you don't have an account tou can create one for free to test...

Any help will be appreciated.

Thanks.
fefe78
 
Posts: 2
Joined: Fri May 17, 2013 7:42 am

Re: Automatic login into specific site

Postby metulburr » Fri May 17, 2013 12:53 pm

and your code is?
New Users, Read This
version Python 3.3.2 and 2.7.5, tkinter 8.5, pyqt 4.8.4, pygame 1.9.2 pre
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
User avatar
metulburr
 
Posts: 1103
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Automatic login into specific site

Postby fefe78 » Fri May 17, 2013 12:59 pm

simply this:

Code: Select all
from requests import session
import os

payload = {
    'submit': 'Log in',
    'username': 'xxxx',
    'password': 'xxxxx'
}

with session() as c:
    c.post('https://account.dyn.com/entrance', data=payload)
    request = c.get('https://account.dyn.com/profile/')
    print request.headers
    print request.text



And here is the POST request taken from a browser access:

Code: Select all
iov_id   0400tyDoXSFjKeoNf94lis1ztlZtWBcopyaUCoK31Bznnk6pxCmGh5pZFJla/gfgPTUOjQ6Q1abuE9oMgog1WtCs0txF6Ft8Ea5XAHtlrOPcoluxmyTC4THv7A1zM3XireXLCHex/Y96FFckU80UeS1q1/HBQm916StC15tFwbb5NkVtrNHzt95ePs1PJVyb/7L8+7gyLtPHR6Av0nLv/jsDO5gWSO2+NA4ZT7V3vhKKv198nTs/3e3TI3A+k9XRlIy/H7yJ6+3vWhAdX8AftgEzohO657neTIbcRSe2o5iRyuVT16UOV5X35DP2eJhTmzT3xA9x3qRKbjN8jTwX2Y63p0LH+jv8B8PW6EuQOlw0fYYM0LX/nSTBMb8i3Z8peI9cv9eOvsyvTBVOr8MeFigMd8UvRkxkPz1xa177w9ypqz8JB/s4Mwp5brXiJgdMwpNw4rDyBxgqilnjOTRqovjtf7mZnC9N+MV7iUTrLire1w7cdMgGDVx0tcCKkY8WHDcKDX8icOWPZcz7cCunQS9MKzlVT8kOFdaE0gR5GYBT5U3X4nZR42Q+uLhW1HQIpGtAAfOPjzqyODLxkOl70GQd7o9qpLt2ZL85nWbFohFqQsn9oLrVw9w/leLeuellwPafaslQ9esTVr79rxZ7qeEFWWhywhmCBcBqdSl3vfLLR9cWIPFeXuTiRgnptPkeNQJ0Wx+lXsQjcodqQwmHFDdvxqHpBWW0Kmz41eTi2qvPS1MsPiZXdNCqfPGIqcnK/8QwDfJnwG91UwCK6/pdx/gqwseIxv3To6uQwvXIt6mxUWAhh+HZ521Xpr+w+P6aM0chJcuNJRYlpUhq7f/mSBizkZu3WZVNuFbIFtojPmW3ylADhxAlDV/8ZeMr0YV5w5CLvF3XE7WHpkJm5qN2tp4CReLjqF5d4EP/TkQc2bZC8NZvcOGavwBT68P8aKBtmpM1vDR/P0RlDnI0Skn5atbGpuRkYvVdFKNdYtBUbpa7l0Ht5wzSs2XUoceIxv3To6uQwvXIt6mxUWAhh+HZ521Xpr+w+P6aM0chJcuNJRYlpUgSR3D8hd7G2w==
multiform   2A47FFDF461C6783788C03B87A4D8DA9F9
password   xxxxxx
submit   Log in
username   xxxxxx
fefe78
 
Posts: 2
Joined: Fri May 17, 2013 7:42 am


Return to Web Development

Who is online

Users browsing this forum: No registered users and 1 guest