Advertisement
Guest User

Untitled

a guest
Sep 11th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. import requests, lxml.html
  2.  
  3. # USERNAME = 'usuariox'
  4. # PASSWORD = 'contraseniax'
  5. # LOGIN_URL = 'http://apps.iplyc.gov.ar/ludopatia/login'
  6. # URL = 'http://apps.iplyc.gov.ar/ludopatia/filter-autoexcluidos'
  7.  
  8.  
  9. s = requests.session()
  10.  
  11. ### Here, we're getting the login page and then grabbing hidden form
  12. ### fields.  We're probably also getting several session cookies too.
  13. login = s.get('https://apps.iplyc.gov.ar/ludopatia/login', verify = False)
  14. login_html = lxml.html.fromstring(login.text)
  15. hidden_inputs = login_html.xpath(r'//form//input[@type="hidden"]')
  16. form = {x.attrib["name"]: x.attrib["value"] for x in hidden_inputs}
  17. print(form)
  18.  
  19. ### Now that we have the hidden form fields, let's add in our
  20. ### username and password.
  21. form['USERNAME'] = 'gaitacar' # Enter an email here.  Not mine.
  22. form['PASSWORD'] = 'JYrjGNlAv334' # I'm definitely not telling you my password.
  23. response = s.post('https://apps.iplyc.gov.ar/ludopatia/login', data=form)
  24.  
  25. ### How can we tell that we logged in?  Well, these worked for me:
  26. response.url
  27. 'usuariox' in response.text
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement