import mechanize
br = mechanize.Browser()
br.open('someurl.com')
br.select_form(nr=0)
br.form['user'] = 'myname'
br.form['pw'] ='pw'
req=br.submit()
提交后,我登录了一个新页面,这进一步要求我点击下一个'
<input type="submit" value=" Next " name="B1"> <input type="reset" value=" Clear " name="B2"></td>
我该怎么办?
答案 0 :(得分:0)
因此,解决方案非常简单,因为一旦您拥有浏览器实例,它就像真正的浏览器一样;在这个问题上,您可以在第一次成功提交后再次提交。
所以,这是原始代码:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<div class='sidebar'>
<table class="dynamicHeight">
<thead>
<tr>
<th>Header</th>
</tr>
</thead>
<tbody>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
<tr><td>Body Row</td></tr>
</tbody>
</table>
</div>
然后重复你所做的事情以转到下一页(下面是完整的解决方案):
import mechanize
br = mechanize.Browser()
br.open('someurl.com')
br.select_form(nr=0)
br.form['user'] = 'myname'
br.form['pw'] ='pw'
req=br.submit()