Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests, lxml.html
- # USERNAME = 'usuariox'
- # PASSWORD = 'contraseniax'
- # LOGIN_URL = 'http://apps.iplyc.gov.ar/ludopatia/login'
- # URL = 'http://apps.iplyc.gov.ar/ludopatia/filter-autoexcluidos'
- s = requests.session()
- ### Here, we're getting the login page and then grabbing hidden form
- ### fields. We're probably also getting several session cookies too.
- login = s.get('https://apps.iplyc.gov.ar/ludopatia/login', verify = False)
- login_html = lxml.html.fromstring(login.text)
- hidden_inputs = login_html.xpath(r'//form//input[@type="hidden"]')
- form = {x.attrib["name"]: x.attrib["value"] for x in hidden_inputs}
- print(form)
- ### Now that we have the hidden form fields, let's add in our
- ### username and password.
- form['USERNAME'] = 'gaitacar' # Enter an email here. Not mine.
- form['PASSWORD'] = 'JYrjGNlAv334' # I'm definitely not telling you my password.
- response = s.post('https://apps.iplyc.gov.ar/ludopatia/login', data=form)
- ### How can we tell that we logged in? Well, these worked for me:
- response.url
- 'usuariox' in response.text
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement