내가

2017-09-13 4 views
0
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

일단 브라우저 인스턴스가 생기면 솔루션은 매우 간단합니다. 실제 브라우저처럼 작동합니다. 이 문제는 첫 번째 제출 성공 후 다시 제출할 수 있습니다.

는 그런 다음 다음 페이지로 이동 한 일을 반복한다 (아래있는 완벽한 솔루션)
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() 

:

import mechanize 
br = mechanize.Browser() # now you are at first login page 
br.open('someurl.com') 
br.select_form(nr=0) # select the form from the first login page 
br.form['user'] = 'myname' 
br.form['pw'] ='pw' 
req=br.submit() # now you are at second login page 
br.select_form(nr=0) # select the form from the second login page 
br.form['user'] = 'myname' 
br.form['pw'] ='pw' 
req=br.submit() 

그래서, 여기에 원래 코드