0
https://portals.broadinstitute.org/cmap/index.jsp이 질문에 대한 답변을 다시 사용하겠습니다 : https://stackoverflow.com/a/22547541/651779. 이것은 올바르게 작동하는 데 사용되었습니다. 그러나 지금 실행하면 승인이 거부됩니다. 사용자 이름과 암호가 정확합니다. 이것은 (채워 사용자 이름과 암호) URL을 제공인증 실패로 웹 사이트에 로그인
login_url = 'http://www.broadinstitute.org/cmap/j_security_check'
login_values = urllib.parse.urlencode({'j_username': user,
'j_password': pwd,
'submit': 'sign in'})
print(login_url+'?'+login_values)
:
코드 아래http://www.broadinstitute.org/cmap/j_security_check?j_username=<username>&j_password=<password>&submit=sign+in
내 브라우저에서 올바르게에서 저를 로그온 할 붙여, 그래서 사용자 이름과 암호가 여전히 좋은지 확인하십시오.
payload_submit_signature = bytes(login_values, 'ascii')
cj = http.cookiejar.CookieJar()
opener = urllib.request.build_opener(
urllib.request.HTTPRedirectHandler(),
urllib.request.HTTPHandler(debuglevel=0),
urllib.request.HTTPSHandler(debuglevel=0),
urllib.request.HTTPCookieProcessor(cj))
opener.open(submit_signature_url) #First call to capture the JSESSIONID
resp = opener.open(login_url, payload_submit_signature)
for cookie in cj:
print (cookie.name, cookie.value, cookie.domain, cookie.expires, cookie.secure) #etc etc
이전 스택 응답에 따라 쿠키를 먼저 설정해야합니다. 위의 인쇄 결과는
JSESSIONID B2CFD19CBB9105EC2DC4D75DD7C3C0C9 portals.broadinstitute.org None True
으로 나타납니다.
print(resp.read())
잘못된 사용자 - 비밀번호 조합을 입력 할 때와 동일한 hmtl 페이지를 제공합니다. 왜 제대로 보내지 않는거야?
이 왜'requests'를 사용하지 않는? –
@ tmadam requests.Session()을 p = s.post ('http://www.broadinstitute.org/ cmap/j_security_check ', data = payload) print (p.text) 또한 인증 오류를 발생시킵니다. –