Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests, lxml.html
- s = requests.session()
- login = s.get('http://localhost:8090/index.php')
- 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 (s.cookies)
- #print(form)
- form['login_name'] = 'glpi'
- form['login_password'] = 'glpi'
- headers = {
- 'Host': 'localhost:8090',
- 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0',
- 'Accept': '*/*',
- 'Accept-Language': 'en-US,en;q=0.5',
- 'X-Requested-With': 'XMLHttpRequest',
- 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
- 'Referer': 'http://localhost:8090/login.php',
- 'DNT': '1',
- 'Connection': 'keep-alive',
- 'Pragma': 'no-cache',
- 'Cache-Control': 'no-cache',
- }
- response = s.post('http://localhost:8090/front/central.php', headers=headers, data=form)
- headers = {
- 'Host': 'localhost:8090',
- 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0',
- 'Accept': '*/*',
- 'Accept-Language': 'en-US,en;q=0.5',
- 'X-Requested-With': 'XMLHttpRequest',
- 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
- 'Referer': 'http://localhost:8090/front/ticket.form.php?id=1',
- 'DNT': '1',
- 'Connection': 'keep-alive',
- 'Pragma': 'no-cache',
- 'Cache-Control': 'no-cache',
- }
- data = [
- ('target', '/front/ticket.form.php'),
- ('itemtype', 'Ticket'),
- ('glpi_tab', 'TicketTask$1'),
- ('id', '1'),
- ('template_preview', '0'),
- ]
- response = requests.post('http://localhost:8090/ajax/common.tabs.php', headers=headers, data=data)
- # O usando la cookie mas explicita:
- #
- # response = requests.post('http://localhost:8090/ajax/common.tabs.php', headers=headers, coockies=cookies, data=data)
- #
- # Si en el request envio las cookies como
- # cookies = {
- # 'PHPSESSID': s.cookies['PHPSESSID'],
- # }
- #
- # Tampoco funciona.
- print (response.text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement