Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 8th, 2004, 06:00 PM
Leet Llama Leet Llama is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 8 Leet Llama User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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?

Reply With Quote
  #2  
Old July 8th, 2004, 06:28 PM
Grim Archon's Avatar
Grim Archon Grim Archon is offline
Mini me.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Location: Cambridge, UK
Posts: 783 Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)  Folding Points: 1488 Folding Title: Novice Folder
Time spent in forums: 3 Days 2 h 15 m 57 sec
Reputation Power: 7
Send a message via MSN to Grim Archon
Is the Login page a normal html form? What method is used (GET or POST)?
__________________
*** Experimental Python Markup CGI V2 ***

Reply With Quote
  #3  
Old July 8th, 2004, 06:35 PM
Leet Llama Leet Llama is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 8 Leet Llama User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
normal html form

Reply With Quote
  #4  
Old July 8th, 2004, 07:10 PM
Grim Archon's Avatar
Grim Archon Grim Archon is offline
Mini me.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Location: Cambridge, UK
Posts: 783 Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)  Folding Points: 1488 Folding Title: Novice Folder
Time spent in forums: 3 Days 2 h 15 m 57 sec
Reputation Power: 7
Send a message via MSN to Grim Archon
GET or POST?

Reply With Quote
  #5  
Old July 8th, 2004, 07:12 PM
Leet Llama Leet Llama is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 8 Leet Llama User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Get

Reply With Quote
  #6  
Old July 9th, 2004, 12:06 AM
Leet Llama Leet Llama is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 8 Leet Llama User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
if u could show me some source code I'd appreciate it

Reply With Quote
  #7  
Old July 9th, 2004, 04:22 AM
Grim Archon's Avatar
Grim Archon Grim Archon is offline
Mini me.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Nov 2003
Location: Cambridge, UK
Posts: 783 Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)Grim Archon User rank is Corporal (100 - 500 Reputation Level)  Folding Points: 1488 Folding Title: Novice Folder
Time spent in forums: 3 Days 2 h 15 m 57 sec
Reputation Power: 7
Send a message via MSN to Grim Archon
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

Reply With Quote
  #8  
Old July 9th, 2004, 03:52 PM
Leet Llama Leet Llama is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 8 Leet Llama User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
wow, thanks a lot!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Website login program


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway