Guest User

Untitled

a guest
Mar 5th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. #import libraries
  2. import csv
  3. import requests
  4. from bs4 import BeautifulSoup
  5.  
  6. URL="http://thuvientulap.org/login.aspx"
  7.  
  8. username="user"
  9. password="password"
  10.  
  11. s=requests.Session()
  12. r=s.get(URL)
  13.  
  14. soup=BeautifulSoup(r.content,'html.parser')
  15.  
  16. VIEWSTATE=soup.find(id="__VIEWSTATE")['value']
  17. EVENTVALIDATION=soup.find(id="__EVENTVALIDATION")['value']
  18. VIEWSTATEGENERATOR=soup.find(id="__VIEWSTATEGENERATOR")['value']
  19.  
  20. login_data={"__VIEWSTATE":VIEWSTATE,
  21. "txt_name_login":username,
  22. "txt_password_ogin":password,
  23. "__VIEWSTATE":VIEWSTATE,
  24. "__EVENTVALIDATION":EVENTVALIDATION,
  25. "__VIEWSTATEGENERATORT":VIEWSTATEGENERATOR,
  26. }
  27.  
  28. r = s.post(URL, data=login_data)
  29.  
  30. admin_url =("http://thuvientulap.org/admin.aspx")
  31. r = s.get(admin_url)
  32.  
  33. print (r.url)
  34. print (r.text)
  35.  
  36. import requests
  37. s=requests.Session()
  38. url ="http://thuvientulap.org/login.aspx"
  39. r=s.get(url)
  40. dct=s.cookies.get_dict()#you will get a ASP.net cookie pass it in header
  41. along with other headers
  42.  
  43.  
  44. aid=dct["ASP.NETID"]*
  45. head = {ASP.NETID=jid,.....}*
  46. *check for the correct ASPid-name in request headers
  47. r = s.post(url, data=login_data,headers=head)
Add Comment
Please, Sign In to add comment