From: ken on
Hello All.
im making some website login function with mechanize.browser() module.
but problem is i can't send submit or click submit button with
mechanize click() function, it not working.
how can i submit button or click() function make it work?
i can make it work mechanize.Request and mechanize.urlopen() 's POST
function,but
this time i want to make it work mechanize.browser() which emulate web
browser.
please help me!
thanks in advance


# -*- coding: utf-8 -*-
import sys,os
import mechanize, urllib
import cookielib
from BeautifulSoup import BeautifulSoup,BeautifulStoneSoup,Tag
import datetime, time
import re,sys,os,mechanize,urllib,threading,time, socket
br = mechanize.Browser()
# Cookie Jar
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)

# Browser options
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)

# Follows refresh 0 but not hangs on refresh > 0
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(),
max_time=1)

# Want debugging messages?
br.set_debug_http(True)
br.set_debug_redirects(True)
br.set_debug_responses(True)

br.addheaders = [('User-agent', 'Mozilla/4.0 (compatible; MSIE 7.0b;
Windows NT 5.1)')]

br.clear_history()

br.open('http://xo.nate.com/login.jsp')
html = br.response().read()
#print html
#Show the available forms
for f in br.forms():
print f

# Select the first (index zero) form
#br.select_form(nr=1)
br.select_form(name='f_login')
# Let's search
br.form['ID']= 'prudy'
#br.form['user_password']=['on']
br.form['PASSWD']= 'sotkfkd'
print br.geturl()
br.submit()
html = br.response().read()
print html