mechanize를 사용하여 페이지에 로그인하고 정보를 검색하고 싶습니다.python mechanize를 사용하여 NTLM 인증으로 페이지에 로그인하십시오.
r = br.open('http://intra')
File "bui...e\_mechanize.py", line 203, in open
File "bui...g\mechanize\_mechanize.py", line 255,
in _mech_openmechanize._response.httperror_seek_wrapper: HTTP Error 401: Unauthorized
이 내 코드는 지금까지입니다 : 내가 잘못 뭐하는 거지
import mechanize
import cookielib
# Browser
br = mechanize.Browser()
# Cookie Jar
cj = cookielib.LWPCookieJar()
br.set_cookiejar(cj)
# Browser options
br.set_handle_equiv(True)
# br.set_handle_gzip(True)
br.set_handle_redirect(True)
br.set_handle_referer(True)
br.set_handle_robots(False)
# Follows refresh 0 but not hangs on refresh > 0
br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1)
# If the protected site didn't receive the authentication data you would
# end up with a 410 error in your face
br.add_password('http://intra', 'myusername', 'mypassword')
# User-Agent (this is cheating, ok?)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
# Open some site, let's pick a random one, the first that pops in mind:
# r = br.open('http://google.com')
r = br.open('http://intra')
html = r.read()
# Show the source
print html
내가 뭔가를 인증하려고하지만 당신이 아래에 볼 수 있습니다하지만 그냥 오류 코드 HTTP 401 실패? 예를 들어 http://intra
(내부 페이지)을 방문하십시오. 크롬, 그것은 창문을 열고 사용자 이름/비밀 번호를 한 번 물어 다음 모두 좋다. 이 같은 오픈 모습을 팝업
의 대화 :이 뒤에 이유를 찾을 관리