8
我正在刮一個使用隱藏窗體的網站作爲對付我正在嘗試去做的一種對策。這種形式:如何在Mechanize/Python中設置隱藏表單的值?
<input style="width: 2px; height: 25px" type="hidden" size="1" name="TestJavaScript" />
是罪魁禍首。該表單預計此輸入的值將通過稍後執行的某些JavaScript設置爲「OK」:
function doSignOn() {
window.document.tether.method = "POST";
window.document.tether.action = "https://missionlink.missionfcu.org/MFCU/login.aspx";
window.document.tether.TestJavaScript.value = "OK";
if (window.document.tether.user.value.length < 1) {
alert("Please enter your Member Number.");
return;
}
if (window.document.tether.PIN.value.length < 1) {
alert("Please enter your Password.");
return;
}
// If we're in the service interruption or notice window, put up an alert.
if (now <= interruption_end) {
if (now >= notice_begin) {
alert(prewarn_alert+'\n\nThank you.');
}
}
window.document.tether.submit();
}
聰明。我正在使用機械化來刮頁面,我如何設置此表單項的值?當我打印form
對象在Python中,這裏是什麼樣子:
<tether POST https://missionlink.missionfcu.org/MFCU/login.aspx application/x-www-form-urlencoded
<TextControl(user=)>
<PasswordControl(PIN=)>
<HiddenControl(TestJavaScript=) (readonly)>
<SelectControl(signonDest=[*My Default Destination, Accounts.Activity, Accounts.Summary, Transfers.AddTransfer, SelfService.SelfService])>
>
,因爲它顯示爲「只讀」,我不能修改它,否則它拋出一個異常。當然有一個解決方法,對吧?有任何想法嗎?