|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Website login program
Would anyone happen to have a small python program (with or without gui) that can log a user into a website, at regular intervals?
The program would have to take the following as input 1. the URL of a website (http) 2. the user ID 3. the user pasword 4. click (simulate a keypress or mouse click) on the button to log the user in. if the user could not be logged in, due to the website being overloaded, then it would do a retry at the next interval (where the interval can be supplied by the user, preferably in seconds) Or could someone explain how to do this? |
|
#2
|
||||
|
||||
|
Is the Login page a normal html form? What method is used (GET or POST)?
__________________
*** Experimental Python Markup CGI V2 *** |
|
#3
|
|||
|
|||
|
normal html form
|
|
#4
|
||||
|
||||
|
GET or POST?
|
|
#5
|
|||
|
|||
|
Get
|
|
#6
|
|||
|
|||
|
if u could show me some source code I'd appreciate it
|
|
#7
|
||||
|
||||
|
Here is a simple script:
Code:
import httplib
import time
site = "www.mysite.com"
form = "/cgi-bin/form.py" #the path to the login form processor
username = "MyName"
password = "MyPassword"
form_data = "?USERNAMEFIELD=%s&PASSWORDFIELD=%s"%(username, password) #Change USERNAMEFIELD and PASSWORDFIELD for the form you are using
wait = 10 #Wait period 10 minutes if site is busy.
login_ok = "Thank you for logging in" # Some text that would be on the page if login was okay
while True:
conn = httplib.HTTPConnection(site)
conn.request("GET", form+form_data)
resp = conn.getresponse()
if resp.status == 404:
print "Webpage not found"
break
else:
data1 = resp.read()
print data1
if data1.find(login_ok) != -1:
print "Logged in"
break
else:
print "Trying again in ", wait, "minutes"
time.sleep(wait*60)
If you need help with this then please refer to the Python documentation. grim ![]() |
|
#8
|
|||
|
|||
|
wow, thanks a lot!
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > Website login program |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|