Closed anniehuang921 closed 9 years ago
喂一個form給login, 回傳403
$ pay_load={ 'csrfmiddlewaretoken': res.cookies['csrftoken'] 'email': 'c3h3.tw@gmail.com', 'password': 'c3h33211'} $ url_login="https://university.mongodb.com/login" $ res_login=requests.post(url_login,pay_load) >>> <Response [403]>
從首頁開始登入的code
import requests A=requests.Session() url="https://university.mongodb.com/"#首頁 res=A.get(url) res.cookies['csrftoken'] from pyquery import PyQuery S=PyQuery(res.text) T=S("div.row div p a:not(.btn.btn-action)") source="csrfmiddlewaretoken=MdNg8AP3Ed6ODpdnMqxcXiHaikJdg9NN&email=c3h3.tw%40gmail.com&password=c3h33211" def rep1(text,dic): for i,j in dic.iteritems(): text=text.replace(i,j) return text dic={'=':':','%40':'@'} t1=rep1(source,dic) pay_load=dict(tuple(map(lambda x:x.split(':'),t1.split('&')))) token=res.cookies['csrftoken'] pay_load['csrfmiddlewaretoken']=token pay_load url_login="https://university.mongodb.com/login" res_login=A.post(url_login,pay_load) res_login url_dash="https://university.mongodb.com/dashboard"#資訊放在這裡 res_dash=A.get(url_dash)
喂一個form給login, 回傳403
從首頁開始登入的code