Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Version 2
- import requests
- import re
- url = "https://portal.achieve3000.com/util/login.php"
- 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="
- headers = {
- 'accept': "text/html, */*; q=0.01",
- 'origin': "https://portal.achieve3000.com",
- 'x-requested-with': "XMLHttpRequest",
- 'user-agent': "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3215.0 Safari/537.36",
- 'content-type': "application/x-www-form-urlencoded",
- 'referer': "https://portal.achieve3000.com/index",
- 'accept-encoding': "gzip, deflate, br",
- 'accept-language': "es-ES,es;q=0.9",
- '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",
- 'cache-control': "no-cache",
- 'postman-token': "135cc2fb-3f86-9a44-b0db-dac3cde10957"
- }
- #Make persistence of cookie (Creando peticiones con cookie's persistentes)
- with requests.session() as S:
- login = requests.Request('POST', url, data=payload, headers=headers)
- prepped = S.prepare_request(login) #Opcional pero por si quieres editar cabeceras o algo
- resp = S.send(prepped)#Si no utilizas los anterior simplemente reemplazas prepped por login
- paragraphs = re.search(r'points',str(resp.text))
- if paragraphs:
- lesson_url = "https://portal.achieve3000.com/kb/lessonActivity/save_scored_activity"
- 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}}'
- headers_lesson = {
- 'Host': 'portal.achieve3000.com',
- 'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0',
- 'Accept': 'application/json, text/plain, */*',
- 'Accept-Language': 'es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3',
- 'Accept-Encoding': 'gzip, deflate, br',
- 'X-Requested-With': 'XMLHttpRequest',
- 'X-ACHIEVE-SESSION': 'f9754pnamm4n5qumfpqssbbqp7',
- 'X-ACHIEVE-SESSION-KEY': 'MTEwNDg3OTJ8MTUwNjE0MDE0NQ==',
- 'X-XSRF-TOKEN': '65a9ba727d8f30c0b6d983668a38abb8',
- 'Content-Type': 'application/json;charset=utf-8',
- 'Referer': 'https://portal.achieve3000.com/kb/lesson/?lid=17804&step=14&c=1&asn=',
- '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'
- }
- send_a = requests.Request('POST', lesson_url, data=payload_lesson, headers=headers_lesson)
- preped = S.prepare_request(send_a)
- r = S.send(preped)
- print resp.text
- #print (resp.text) #Logueado xD (Logged)
- #print ("Si te sales del with no tendras la sesion")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement