Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import robobrowser
- import re
- url = 'https://m.facebook.com'
- loggedin_title = 'Facebook' # isto vai servir para confirmarmos que estamos loggedin, vendo o titulo da pagina para onde fomos redirecionados
- browser = robobrowser.RoboBrowser(history=True)
- browser.open(url)
- form = browser.get_form(id='login_form')
- form['email'].value = 'USERNAME'
- form['pass'].value = 'PASSWORD'
- browser.submit_form(form)
- redirect_title = re.compile('<title>(.*?)</title>').search(str(browser.parsed)).group(1)
- if(redirect_title == loggedin_title):
- print('[+] SUCCESS')
- print('Username: {}nPassword: {}'.format(form['email'].value, form['pass'].value))
- else:
- print('[-] LOGIN FAILED')
- Warning (from warnings module):
- File "C:UsersEDUARDOAppDataLocalProgramsPythonPython36libsite-packagesbs4__init__.py", line 181
- markup_type=markup_type))
- UserWarning: No parser was explicitly specified, so I'm using the best available HTML parser for this system ("lxml"). This usually isn't a problem, but if you run this code on another system, or in a different virtual environment, it may use a different parser and behave differently.
- The code that caused this warning is on line 1 of the file <string>. To get rid of this warning, change code that looks like this:
- BeautifulSoup(YOUR_MARKUP})
- to this:
- BeautifulSoup(YOUR_MARKUP, "lxml")
- Traceback (most recent call last):
- File "C:UsersEDDocumentsPythonPythonPythonLOGINlogin.py", line 13, in <module>
- browser.submit_form(form)
- File "C:UsersEDAppDataLocalProgramsPythonPython36libsite-packagesrobobrowserbrowser.py", line 339, in submit_form
- payload = form.serialize(submit=submit)
- File "C:UsersEDAppDataLocalProgramsPythonPython36libsite-packagesrobobrowserformsform.py", line 226, in serialize
- include_fields = prepare_fields(self.fields, self.submit_fields, submit)
- File "C:UsersEDAppDataLocalProgramsPythonPython36libsite-packagesrobobrowserformsform.py", line 154, in prepare_fields
- raise exceptions.InvalidSubmitError()
- robobrowser.exceptions.InvalidSubmitError
Add Comment
Please, Sign In to add comment