如何使 python mechanize 忽略下拉约束
我正在尝试使用 python mechanize 将 Excel 文件中的数据填充到网页中。
b = Browser()
b.open("http://something/LoginForm.aspx")
b.select_form(nr=0)
b["ctl00$ContentPlaceHolder1$usertext"] = "username"
b["ctl00$ContentPlaceHolder1$passtext"] = "password"
b.submit()
b.select_form(nr=0)
问题是,当一个下拉菜单发生变化时,另一个下拉菜单也会发生变化。但在此之前我已经知道要在另一个下拉列表中填写什么内容。我可以强制机械化以这种方式填充它吗?
使用 urllib 我什至无法登录此页面...
I'm trying to use python mechanize to fill data into a webpage from an excel file.
b = Browser()
b.open("http://something/LoginForm.aspx")
b.select_form(nr=0)
b["ctl00$ContentPlaceHolder1$usertext"] = "username"
b["ctl00$ContentPlaceHolder1$passtext"] = "password"
b.submit()
b.select_form(nr=0)
The problem is that when a dropdown is changed, another dropdown menu changes. But I already know what to fill in the other dropdown before this. Can I force mechanize to fill it that way anyway?
With urllib i am not even able to login to this page...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这需要一个例子。根据我对 aspx 页面的经验,它不使用 ajax。第一个控件可能正在提交并导致整个页面使用另一个下拉列表中的新值重新加载。
还可能存在需要与表单对应的 VIEWSTATE 变量,这意味着可能无法按照您的意愿在表单中构建条目。
This needs an example. In my experience with aspx pages is that it doesn't use ajax. The first control is probably submitting and causing the whole page to reload with the new values in the other dropdown.
There may also be VIEWSTATE variables that need to correspond with the form, which means it is probably impossible to build the entries in the form as you would like.