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}
- 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)
- cookies = {
- 'PHPSESSID': '2oigal8dk7o3faaqm9ebs21tr6',
- }
- 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, cookies=cookies, data=data)
- print (response3.text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement