I’m interfacing a page that needs a login with mechanize. It uses some javascript on the front page making using mechanize straight-up more difficult. I know what form I have to submit to log-in – the one always generated by the js, the same every time. How can I make mechanize just submit a custom form that isn’t on the page? Basically equivalent to this perl problem but in Python.
I’m interfacing a page that needs a login with mechanize. It uses some javascript
Share
(NOTE: This came up again recently and I actually got it to work now.)
This seems to work:
URLis the full URL of the visited site.BASE_URLis the directory the URL is in.FORM_HTMLis any HTML that has aformelement, e.g.:For some reason,
mechanize._form.ParseStringreturns two forms. The first is aGETrequest to the base URL with no inputs; the second, the properly parsed form fromFORM_HTML.