Guest User

Untitled

a guest
Jan 16th, 2018
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. import robobrowser
  2. import re
  3.  
  4. url = 'https://m.facebook.com'
  5. loggedin_title = 'Facebook' # isto vai servir para confirmarmos que estamos loggedin, vendo o titulo da pagina para onde fomos redirecionados
  6.  
  7. browser = robobrowser.RoboBrowser(history=True)
  8. browser.open(url)
  9.  
  10. form = browser.get_form(id='login_form')
  11. form['email'].value = 'USERNAME'
  12. form['pass'].value = 'PASSWORD'
  13. browser.submit_form(form)
  14.  
  15. redirect_title = re.compile('<title>(.*?)</title>').search(str(browser.parsed)).group(1)
  16.  
  17. if(redirect_title == loggedin_title):
  18. print('[+] SUCCESS')
  19. print('Username: {}nPassword: {}'.format(form['email'].value, form['pass'].value))
  20. else:
  21. print('[-] LOGIN FAILED')
  22.  
  23. Warning (from warnings module):
  24. File "C:UsersEDUARDOAppDataLocalProgramsPythonPython36libsite-packagesbs4__init__.py", line 181
  25. markup_type=markup_type))
  26. 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.
  27.  
  28. 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:
  29.  
  30. BeautifulSoup(YOUR_MARKUP})
  31.  
  32. to this:
  33.  
  34. BeautifulSoup(YOUR_MARKUP, "lxml")
  35.  
  36. Traceback (most recent call last):
  37. File "C:UsersEDDocumentsPythonPythonPythonLOGINlogin.py", line 13, in <module>
  38. browser.submit_form(form)
  39. File "C:UsersEDAppDataLocalProgramsPythonPython36libsite-packagesrobobrowserbrowser.py", line 339, in submit_form
  40. payload = form.serialize(submit=submit)
  41. File "C:UsersEDAppDataLocalProgramsPythonPython36libsite-packagesrobobrowserformsform.py", line 226, in serialize
  42. include_fields = prepare_fields(self.fields, self.submit_fields, submit)
  43. File "C:UsersEDAppDataLocalProgramsPythonPython36libsite-packagesrobobrowserformsform.py", line 154, in prepare_fields
  44. raise exceptions.InvalidSubmitError()
  45. robobrowser.exceptions.InvalidSubmitError
Add Comment
Please, Sign In to add comment