im creating some script with mechanize.browser module.
one of the problems is everything else, everything is fine, but when the submit () form, it does not work,
therefore, I found a part of the source of suspicion.
in the html source I was found such as the following.
im thinking, loginCheck (this) creates a problem when submitting the form.
but how to handle such a javascript function with a mechanization module, so I can
successfully send the form and get the result?
Below is the websource snippet associated with the loginCheck (this) javascript function.
function init(){
FRMLOGIN.ID.focus();
}
function loginCheck(f){
if(chkNull(f.ID, "아이디를"))
return false;
if(chkNull(f.PWD, "패스워드를"))
return false;
f.action = (f.SECCHK.checked) ? "https://user.buddybuddy.co.kr/Login/Login.asp" : "http://user.buddybuddy.co.kr/Login/Login.asp";
}
I know that mechanization does not support javascript, so I want to do progammatically loginCheck ()
with python mechanization code.
Can anyone help me make this javascript function for python mechanization
translated code?
?
!
import sys,os
import mechanize, urllib
import cookielib
from BeautifulSoup import BeautifulSoup,BeautifulStoneSoup,Tag
import datetime, time, socket
import re,sys,os,mechanize,urllib,time
br = mechanize.Browser()
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
br.set_handle_equiv(True)
br.set_handle_gzip(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
br.set_debug_http(True)
br.set_debug_redirects(True)
br.set_debug_responses(True)
br.addheaders = [('User-agent', 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.6')]
br.open('http://user.buddybuddy.co.kr/Login/LoginForm.asp?URL=')
html = br.response().read()
print html
br.select_form(name='FRMLOGIN')
print br.viewing_html()
br.form['ID']='psh7943'
br.form['PWD']='qkrthgus'
br.submit()
print br.response().read()
- .. !!