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])>
>
,因为它显示为“只读”,我不能修改它,否则它抛出一个异常。当然有一个解决方法,对吧?有任何想法吗?