I'm using Mechanize lib (with Python) to create a program to log in a system. But for that system the option Browser.Submit not works. So I'm trying to force my program to click in the button "login". Does anybody know if it's possible with Mechanize?
Asked
Active
Viewed 2,135 times
3 Answers
1
You might consider looking at twill, if you haven't already. Twill is based on the mechanize package, and has a submit function that can be used to click buttons.

ANortonsmith
- 146
- 5
0
You may also want to have a look at ghost.py which provides a headless WebKit browser accessible via Python (basically a Python variant of PhantomJS). Either should have no problem clicking on an arbitrary button (after filling out a form, or even evaluating some JS).

Dave Jones
- 1,080
- 11
- 11
0
Try RoboBrowser, which is built on top of Mechanize and Beautiful Soup.
Example code:
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)`

AutomaticStatic
- 1,661
- 3
- 21
- 42