views:

394

answers:

0

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'