即時通過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