尝试使用Python mechanize登录到网页。因为我在找到正确的表单时遇到了一个问题,我将把一些代码复制到这里以供将来的用户使用,而不是发布URL(代码可能会更改)。我读了this,但似乎没有一个明确的答案。在
总之,我在this tutorial中使用mechanize做了所有事情,直到我得到表单为止。在
当我打电话给:for form in br.forms():
print form
我回来了:
^{pr2}$
看看原始的HTML,我看到了:Email<.>
<.input autofocus="autofocus" id="affiliate_email">
name="affiliate[email]" size="30" type="email" />
但是,当我试图选择电子邮件字段时,我得到一个表单未找到错误。在br.select_form(name="affiliate[email]")
# updated to
br.select_form(nr=0)
# Now what do I do here to enter something into that form?
br.form['someIDhere']='myEmail@example.com'
我还尝试过使用表单ID和其他许多可能的表单名称。我不明白为什么要用br.表格()返回那些奇怪的结果,这是否意味着该网站正在使用javascript登录表单?在
提前谢谢你!在