Advertisement
Guest User

Version que funciona

a guest
Jul 10th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.76 KB | None | 0 0
  1. import requests, lxml.html
  2.  
  3. s = requests.session()
  4. login = s.get('http://localhost:8090/index.php')
  5. login_html = lxml.html.fromstring(login.text)
  6. hidden_inputs = login_html.xpath(r'//form//input[@type="hidden"]')
  7. form = {x.attrib["name"]: x.attrib["value"] for x in hidden_inputs}
  8.  
  9. form['login_name'] = 'glpi'
  10. form['login_password'] = 'glpi'
  11.  
  12. headers = {
  13.     'Host': 'localhost:8090',
  14.     'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0',
  15.     'Accept': '*/*',
  16.     'Accept-Language': 'en-US,en;q=0.5',
  17.     'X-Requested-With': 'XMLHttpRequest',
  18.     'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  19.     'Referer': 'http://localhost:8090/login.php',
  20.     'DNT': '1',
  21.     'Connection': 'keep-alive',
  22.     'Pragma': 'no-cache',
  23.     'Cache-Control': 'no-cache',
  24. }
  25.  
  26. response = s.post('http://localhost:8090/front/central.php', headers=headers, data=form)
  27.  
  28. cookies = {
  29.     'PHPSESSID': '2oigal8dk7o3faaqm9ebs21tr6',
  30. }
  31.  
  32. headers = {
  33.     'Host': 'localhost:8090',
  34.     'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0',
  35.     'Accept': '*/*',
  36.     'Accept-Language': 'en-US,en;q=0.5',
  37.     'X-Requested-With': 'XMLHttpRequest',
  38.     'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
  39.     'Referer': 'http://localhost:8090/front/ticket.form.php?id=1',
  40.     'DNT': '1',
  41.     'Connection': 'keep-alive',
  42.     'Pragma': 'no-cache',
  43.     'Cache-Control': 'no-cache',
  44. }
  45.  
  46. data = [
  47.   ('target', '/front/ticket.form.php'),
  48.   ('itemtype', 'Ticket'),
  49.   ('glpi_tab', 'TicketTask$1'),
  50.   ('id', '1'),
  51.   ('template_preview', '0'),
  52. ]
  53.  
  54. response = requests.post('http://localhost:8090/ajax/common.tabs.php', headers=headers, cookies=cookies, data=data)
  55.  
  56.  
  57. print (response3.text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement