python mechanize javascript submit button problem! -


Creating some scripts with the imize.browser module.

One of the problem is that everything is fine

I found the source of html as if it was found in the following form.

im thinking, logging (this) is having problems while submitting the form.

But how to create such a javascript function with a shifter, so I

can successfully submit the form and get the results?

The following is the website snippet that is related to the login chain (this) JavaScript function.

  function init () {FRMLOGIN.ID .focus (); } Function login check (f) {if (chkNull (f.ID, "아이디 를")) return false; If (chkNull (f.PWD, "패스워드 를")) return false; //f.target = "ifrmLoginHidden"; F.action = (f.secchk.checked)? "Https://user.buddybuddy.co.kr/Login/Login.asp": "http://user.buddybuddy.co.kr/Login/Login.asp"; }  

I know that mechanized does not support Javascript, so I want to make progammatically loginCrack ()

Function with Python McKayage Code.

Translated Code

So can you log in properly with the website?

If so much appreciated!

  # - * - coding: cp949 - * - Import system, OS import mechanism, URLIB import beautiful soup import cookie beautiful soup, beautiful stone soup, tag import datetime , Time, socket import re, system, OS, machine, urlib, time br = mechanize.Browser () cj = cookielib.LWPCookieJar () br.set_cookiejar (cj) # browser option 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) #Refresh is not refreshing at 0; 0 br.set_handle_refresh (mechanize._http.HTTPRefreshProcessor (), max_time = 1) # Want a debugging message? Br.set_debug_http (True) br.set_debug_redirects (True) br.set_debug_responses (True) # User-agent (this is fraud, right?) Br.addheaders = [('User-agent', 'Mozilla / 5.0 (Windows; U; windows NT 6.0; N-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') br.viewing_html () br.form ['id'] = 'psh7943' br.form ['pwd'] = 'qkrthgus' Br.submit () print br.response (). Read ()  

If someone can help me .. much appreciated!

You can go through the logging process in your browser and check (like Firefox in Firebug , Developer Tools in Chrome etc.) Click OK button. Usually this is a post request with data taken from the login form. What data is sent in this request and execute your own post request on this:

  mechanize.urlopen (URL, POST_DATA).  

You can remove pOST_DATA (and post_url) from the form object of the McKenzie:

  form.click_request_data ()  

But you may need to do some modifications.

Very simple example:

  br.select_form (name = 'form_name') br.form ['login'] = 'login' br.form ['pass' ] = 'Pass' post_url, post_data, headers = br.form.click_request_data () mechanize.urlopen (post_url, post_data)  

Comments