python urllib post question

Posted by paul on Stack Overflow See other posts from Stack Overflow or by paul
Published on 2010-05-23T13:53:01Z Indexed on 2010/05/23 14:00 UTC
Read the original article Hit count: 571

Filed under:
|
|
|

hello ALL

im making some simple python post script but it not working well.

there is 2 part to have to login.

first login is using 'http://mybuddy.buddybuddy.co.kr/userinfo/UserInfo.asp' this one.

and second login is using 'http://user.buddybuddy.co.kr/usercheck/UserCheckPWExec.asp'

i can login first login page, but i couldn't login second page website.

and return some error 'illegal access' such like .

i heard this is related with some cooke but i don't know how to implement to resolve this problem.

if anyone can help me much appreciated!! Thanks!

import re,sys,os,mechanize,urllib,time
import datetime,socket


params = urllib.urlencode({'ID':'ph896011', 'PWD':'pk1089' })
rq = mechanize.Request("http://mybuddy.buddybuddy.co.kr/userinfo/UserInfo.asp", params)
rs = mechanize.urlopen(rq)
data = rs.read() 

logged_fail = r';history.back();</script>'  in data                                             
if not logged_fail:
 print 'login success'
 try:
  params = urllib.urlencode({'PASSWORD':'pk1089'})
  rq = mechanize.Request("http://user.buddybuddy.co.kr/usercheck/UserCheckPWExec.asp", params )
  rs = mechanize.urlopen(rq)
  data = rs.read()
  print data
 except:
  print 'error'

© Stack Overflow or respective owner

Related posts about python

Related posts about urllib2