logging into secure website with script

Discussion in 'Python' started by dpoehls, Jan 25, 2006.

  1. dpoehls

    dpoehls Guest

    Hello there,

    I am new to python, and shell scriping in general..I have done quite a
    bit of php, but that it about it. Anyhow, I am wondering if it would be
    possible to write a python script that would login to a password
    enabled site (qmailadmin) and then be able to add a new account. I
    imagine it could be done by accessing the website and then it would
    send POSTs to the website? If this makes no sense, I apologize, just
    wondering if anyone could point me in the right direction. Thanks ahead
    of time!
     
    dpoehls, Jan 25, 2006
    #1
    1. Advertisements

  2. dpoehls

    James Stroud Guest

    dpoehls wrote:
    > Hello there,
    >
    > I am new to python, and shell scriping in general..I have done quite a
    > bit of php, but that it about it. Anyhow, I am wondering if it would be
    > possible to write a python script that would login to a password
    > enabled site (qmailadmin) and then be able to add a new account. I
    > imagine it could be done by accessing the website and then it would
    > send POSTs to the website? If this makes no sense, I apologize, just
    > wondering if anyone could point me in the right direction. Thanks ahead
    > of time!
    >


    Spend some time perusing this code:

    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/302930

    It helped me with a similar problem. I'm not sure if it works for https.

    If the form is using POST to "hide" the login, just suck the web page
    and change POST to GET. Then use your sucked webpage and submit your
    login from it. You will then see the fields (separated by "+"s and the
    values, separated from the fields by "="s). Use the fields and values to
    populate the "txdata" dictionary in the example using urllib.urlencode
    (an example is in the discussion).

    James
     
    James Stroud, Jan 25, 2006
    #2
    1. Advertisements

  3. dpoehls

    Fuzzyman Guest

    dpoehls wrote:
    > Hello there,
    >
    > I am new to python, and shell scriping in general..I have done quite a
    > bit of php, but that it about it. Anyhow, I am wondering if it would be
    > possible to write a python script that would login to a password
    > enabled site (qmailadmin) and then be able to add a new account. I
    > imagine it could be done by accessing the website and then it would
    > send POSTs to the website? If this makes no sense, I apologize, just
    > wondering if anyone could point me in the right direction. Thanks ahead
    > of time!


    You should use urllib2 to fetch URLs. See :

    http://www.voidspace.org.uk/python/articles/urllib2.shtml

    urllib2 will also allow you to do POST.

    How you handle the password depends on whether it is by a form, or by
    basic authentication. For basic authentication see :

    http://www.voidspace.org.uk/python/articles/authentication.shtml

    If it is through a form, you can use ClientForm. Alternatively just
    manually do the POST from urllib2. You may want to use
    ClientCookie/cookielib for (automatic) cookie handling :

    http://www.voidspace.org.uk/python/articles/cookielib.shtml

    All the best,

    Fuzzyman
    http://www.voidspace.org.uk/python/index.shtml
     
    Fuzzyman, Jan 25, 2006
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Antwerp
    Replies:
    0
    Views:
    1,323
    Antwerp
    Feb 15, 2005
  2. A.M
    Replies:
    5
    Views:
    5,783
    Teemu Keiski
    Jun 8, 2004
  3. Brian Henry

    automatically logging into a website

    Brian Henry, Apr 29, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    4,471
    Herfried K. Wagner [MVP]
    Apr 29, 2005
  4. MotorcycleIke

    logging into a website on an external server

    MotorcycleIke, Sep 21, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    557
    MotorcycleIke
    Sep 22, 2005
  5. Mufasa
    Replies:
    0
    Views:
    930
    Mufasa
    Jun 10, 2007
  6. James_Dean
    Replies:
    0
    Views:
    637
    James_Dean
    Jun 27, 2007
  7. Antwerp
    Replies:
    3
    Views:
    496
    Antwerp
    Feb 17, 2005
  8. Tim Daneliuk

    Need Pattern For Logging Into A Website

    Tim Daneliuk, Jan 25, 2013, in forum: Python
    Replies:
    6
    Views:
    304
    Jan WÄ…sak
    Jan 28, 2013
Loading...