Guest User

Untitled

a guest
Jan 3rd, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. import pycurl
  2. from StringIO import StringIO
  3.  
  4. c = pycurl.Curl()
  5. url = 'https://site.ru/index.php'
  6. url1 = 'https://site.ru/index.php?_m=tickets&_a=manage&departmentid=17&ticketstatusid=1'
  7.  
  8.  
  9. c.setopt(pycurl.URL, url)
  10. c.setopt(pycurl.POSTFIELDS, 'username=user&password=pass&_ca=login')
  11. c.setopt(pycurl.COOKIEJAR, "/tmp/cookie.txt")
  12. c.setopt(pycurl.COOKIEFILE, "/tmp/cookie.txt")
  13.  
  14. def __list(url) :
  15. c.setopt(pycurl.URL, url)
  16. c.setopt(pycurl.COOKIEJAR, "/tmp/cookie.txt")
  17. c.setopt(pycurl.COOKIEFILE, "/tmp/cookie.txt")
  18. c.bodyio = StringIO()
  19. c.setopt(pycurl.WRITEFUNCTION, c.bodyio.write)
  20. c.get_body = c.bodyio.getvalue
  21. c.perform()
  22. return c.get_body()
  23.  
  24. print __list(url1)
  25.  
  26. import requests
  27.  
  28. with requests.Session() as s:
  29. # get cookies
  30. s.post(login_url, data=dict(username='user', password='pass', _ca='login'))
  31. # use cookies
  32. html = s.get(ticket_url).content
Add Comment
Please, Sign In to add comment