即时通过mechanize.browser模块制作一些脚本。蟒蛇机械化JavaScript提交按钮的问题!
的问题之一是所有其他的东西是好的,但提交()的形式时,它不工作,
所以我找到了一些嫌疑源部分。
在html源代码中,我发现如下所示。
即时通讯思想,loginCheck(本)决策问题提交表单时。
但如何处理这种与机械化模块JavaScript函数,这样我就可以
成功提交表单,可以接收的结果?
以下是与loginCheck(this)javascript函数相关的websource代码片段。
function init(){
FRMLOGIN.ID.focus();
}
function loginCheck(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";
}
我知道机械化不支持javascript,所以我想progammatically使loginCheck()与Python代码机械化
功能。
任何人都将你一些帮助我做这个JavaScript函数蟒蛇机械化
转换的代码?
这么正确地登录网站?
如果非常感谢!
# -*- coding: cp949-*-
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)
# 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)
# User-Agent (this is cheating, ok?)
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()
如果任何人都可以帮助我..很多欣赏!
请告诉我这些只是虚拟用户名/密码字符串。 – ars 2010-09-26 23:31:22