473,323 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

logging into secure website with script

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!

Jan 25 '06 #1
2 4077
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/Coo.../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
Jan 25 '06 #2

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/a.../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/a...tication.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/a...ookielib.shtml

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

Jan 25 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Yang Li Ke | last post by:
Hi guys, Im about to build a script which will log visitor time spent on my website. I got a few ideas about this, maybe checking visitors ip and storing that info in db with time in and then...
1
by: Nobody | last post by:
I have a website that is built around a web-application that my company purchased. My company has full ownership and administrative rights to this software and its corresponding files. It uses...
2
by: Tor Erik Sønvisen | last post by:
Hi Have the following code: import logging logging.basicConfig(level = logging.DEBUG, format = ' %(message)s', filename = 'rfs.log', filemode = 'w')
0
by: Antwerp | last post by:
Hi, I'm trying to create a perl script that will log into a website (the login form uses POST), navigate to several pages, and append the (html) content parsed from those pages to a seperate log...
2
by: Geoff Wickens | last post by:
I am amazed at how much help I have had in creating my first asp based website from this forum. There are obviously a significant number of real experts who are happy to take the time to help us...
1
by: Maksim Kasimov | last post by:
hello in my modules, I'm using logging module, doing thus (there is a few modules): in module1.py: hdl = logging.StreamHandler() fmt =...
10
by: Thomas Heller | last post by:
I'm about to add some logging calls to a library I have. How can I prevent that the script that uses the library prints 'No handlers could be found for logger "comtypes.client"' when the script...
1
by: S_FOX | last post by:
I am learning VB .Net and Visual Studio .Net while trying to create a Help Desk application for our company's Intranet. Certain pages are available to the MIS Department only. Windows Integrated...
0
by: supern | last post by:
this is my perl script saved as login.pl #!c:/perl/bin/perl.exe $basedir="c:/program files/apache software foundation/apache2.2/cgi-bin"; $datafile="regstr.txt"; $name=$in{'login'};...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.