Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.14 KB | None | 0 0
  1. #Version 2
  2. import requests
  3. import re
  4.  
  5. url = "https://portal.achieve3000.com/util/login.php"
  6.  
  7. payload = "debug=0&login_goto=&lang=1&ajax_yn=Y&flash_version=&=&login_name=angelandres.alvarezcorrea&wz=0&cli=0&login_url=portal.achieve3000.com%252Findex&password=library&cdn=IMAGEASSETSCDN%253A0%253BAPPASSETSCDN%253A0%253BCSSASSETSCDN%253A0%253BJSASSETSCDN%253A0%253BIMAGECDN%253A0%253BAUDIOCDN%253A0%253BVIDEOCDN%253A0%253BDOCSCDN%253A0&banner=1&redirectedFromLE=&program=&domain_id=1&login_name1=&password1=&lost_login_name=&isAjax="
  8.  
  9. headers = {
  10. 'accept': "text/html, */*; q=0.01",
  11. 'origin': "https://portal.achieve3000.com",
  12. 'x-requested-with': "XMLHttpRequest",
  13. 'user-agent': "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3215.0 Safari/537.36",
  14. 'content-type': "application/x-www-form-urlencoded",
  15. 'referer': "https://portal.achieve3000.com/index",
  16. 'accept-encoding': "gzip, deflate, br",
  17. 'accept-language': "es-ES,es;q=0.9",
  18. 'cookie': "LoginLocation=col; LoginDomain=15; visid_incap_505831=BHMHbnAxRpye6TGh3pYt5r9Rw1kAAAAAQUIPAAAAAAASJZ6eOJwas5HFRBrPjSmF; incap_ses_624_505831=3HE8Oj6tZ2OKqYdGA+WoCAKhxFkAAAAARWqKb2x/4xx5TOz+7WYqPA==; _gat=1; incap_ses_485_505831=A+trb65VwXc0qpqohRG7BgShxFkAAAAADW0ixZ8i+WdCwqh1AC0isg==; PHPSESSID=5bt8hbgi3o09f4osvrroe2n2l6; visid_incap_452440=2JZJkesUTIi7DAULXuGLpMhRw1kAAAAAQUIPAAAAAACCEOgfSFtXmcTj0ssBiBPf; incap_ses_484_452440=LRzgLeHLICImSb7nm4O3BiChxFkAAAAAyL5XgOJJwB+WTmPth3vu+w==; _ga=GA1.2.24723138.1505972674; _gid=GA1.2.1969750893.1505972674",
  19. 'cache-control': "no-cache",
  20. 'postman-token': "135cc2fb-3f86-9a44-b0db-dac3cde10957"
  21. }
  22.  
  23. #Make persistence of cookie (Creando peticiones con cookie's persistentes)
  24. with requests.session() as S:
  25. login = requests.Request('POST', url, data=payload, headers=headers)
  26. prepped = S.prepare_request(login) #Opcional pero por si quieres editar cabeceras o algo
  27. resp = S.send(prepped)#Si no utilizas los anterior simplemente reemplazas prepped por login
  28. paragraphs = re.search(r'points',str(resp.text))
  29. if paragraphs:
  30. lesson_url = "https://portal.achieve3000.com/kb/lessonActivity/save_scored_activity"
  31. payload_lesson = '{"activities":[{"id":407655,"activity_type_id":1,"questions":[{"id":1121046,"activityId":407655,"collection":[{"type":"mc","id":7793463,"question":"<p>\\n\\t<img alt=\\"\\" src=\\"/assets/content/images/KB/t/thegiftofsight_jul212017_e_h.gif\\" style=\\"width: 320px; height: 330px;\\" /></p>\\n<p>\\n\\tThink about the Article. Which fits best in the empty box above?</p>","hint":"","answerExplanation":"","items":[{"id":"6d0775a5ec118d97ee62a1f8f0c40551","label":"A new headset can help people with vision problems.","parsedLabel":"A new headset can help people with vision problems.","selected":true},{"id":"d7568d64bd2a2f7478c46487d19dca39","label":"The new headset from eSight has some problems.","parsedLabel":"The new headset from eSight has some problems.","selected":false},{"id":"d9d7248174e51cdb03c94ababb382ea1","label":"The world looks fuzzy to people who have low vision.","parsedLabel":"The world looks fuzzy to people who have low vision.","selected":false},{"id":"11a330c58f7a3506184c504e56807b39","label":"Millions of people around the world have low vision.","parsedLabel":"Millions of people around the world have low vision.","selected":false}],"correctAnswers":1,"isSubmittable":true,"isDirty":true}],"presentedTime":"2017-09-23T04:15:10.503Z","guess":"1"}]}],"general_info":{"lesson_id":"17804","step_id":"14","category_id":"1","activity_id":407655}}'
  32. headers_lesson = {
  33. 'Host': 'portal.achieve3000.com',
  34. 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0',
  35. 'Accept': 'application/json, text/plain, */*',
  36. 'Accept-Language': 'es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3',
  37. 'Accept-Encoding': 'gzip, deflate, br',
  38. 'X-Requested-With': 'XMLHttpRequest',
  39. 'X-ACHIEVE-SESSION': 'f9754pnamm4n5qumfpqssbbqp7',
  40. 'X-ACHIEVE-SESSION-KEY': 'MTEwNDg3OTJ8MTUwNjE0MDE0NQ==',
  41. 'X-XSRF-TOKEN': '65a9ba727d8f30c0b6d983668a38abb8',
  42. 'Content-Type': 'application/json;charset=utf-8',
  43. 'Referer': 'https://portal.achieve3000.com/kb/lesson/?lid=17804&step=14&c=1&asn=',
  44. 'Cookie': 'XSRF-TOKEN=65a9ba727d8f30c0b6d983668a38abb8; visid_incap_505831=TKxzUP8lSmOK1BNZ09a72ty8xVkAAAAAQUIPAAAAAAArD9scMlBcqJ27oo/pjL2X; incap_ses_482_505831=O4N+BaK2+Dcfs+FVjmiwBrbfxVkAAAAAlhC21pTLAVYiA+LwBcAb9w==; incap_ses_622_505831=UynwRKE5OWUTR1CwA8qhCLbfxVkAAAAAnz403uSePoswmTJWyIpF2w==; visid_incap_452440=Eq4Yw4DKRnOBi4SmfwXODb/fxVkAAAAAQUIPAAAAAADe2TnIMmhdpyKGHf6gy5U4; incap_ses_482_452440=6GYLZ3IG9Cn/zuFVjmiwBr/fxVkAAAAAFSWTGHMcag28RHSgcbYhLw==; PHPSESSID=f9754pnamm4n5qumfpqssbbqp7; LoginLocation=col; LoginDomain=15'
  45. }
  46. send_a = requests.Request('POST', lesson_url, data=payload_lesson, headers=headers_lesson)
  47. preped = S.prepare_request(send_a)
  48. r = S.send(preped)
  49. print resp.text
  50.  
  51. #print (resp.text) #Logueado xD (Logged)
  52.  
  53. #print ("Si te sales del with no tendras la sesion")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement