2013-08-28 6 views
3

저는 Mechanize lib (Python과 함께)를 사용하여 시스템에 로그인하는 프로그램을 만듭니다. 그러나 해당 시스템의 경우 Browser.Submit 옵션이 작동하지 않습니다. 그래서 내 프로그램이 "로그인"버튼을 클릭하도록 강요하려고합니다. 기계화가 가능한지 아무도 알지 못합니까?Mechanize (Python)를 사용하여 버튼을 클릭하십시오.

답변

1

twill (아직 찾고 있지 않은 경우)을 고려해보십시오. Twill은 mechanize 패키지를 기반으로하며 단추를 클릭하는 데 사용할 수있는 submit function이 있습니다.

0

또한 ghost.py에서 파이썬 (기본적으로 파이썬 변형 PhantomJS)을 통해 액세스 할 수있는 헤드없는 WebKit 브라우저를 제공 할 수도 있습니다. 폼을 채우거나 일부 JS를 평가 한 후에도 임의의 단추를 클릭해도 아무런 문제가 없어야합니다.

0

Mechanize and Beautiful Soup 위에 구축 된 RoboBrowser를 사용해보십시오.

예제 코드 :

from robobrowser import RoboBrowser 
crawler = RoboBrowser(history=True) 
crawler.open('http://www.whatever.com/') 
search_form = crawler.get_form(attrs={'name':'formName') #This is the name found in <formname=formName> 
search_form['keywords'] = 'search keywords' # In form[] specify the <input name=''> of the subfield within the form element that you're trying to fill in. 
crawler.submit_form(search_form)` 
관련 문제