스크립트 예)
import urllib2
url = "http://192.168.0.1/"
username = "계정"
password = "암호"
realm = "header에서 얻은 realm"
#HTTP 인증방식이 Basic 경우: HTTPBasicAuthHandler() 사용
#HTTP 인증방식이 Digest 경우: HTTPDigestAuthHandler() 사용
handler = urllib2.HTTPBasicAuthHandler()
handler.add_password(realm,url,username,password)
opener = urllib2.build_opener(handler)
urllib2.install_opener(opener)
#가져올 HTML 소스 주소
source = urllib2.urlopen(url+"index.html")
print source.read()
'IT > Programing' 카테고리의 다른 글
[태그/HTML] 링크 or 이미지 마우스오버시 이미지변경 (0) | 2015.03.20 |
---|---|
[오토핫키/AutoHotkey] 기본 명령어 모음 2 (0) | 2015.03.20 |
[오토핫키/AutoHotkey] 기본 명령어 모음 1 (0) | 2015.03.20 |
[오토핫키/AutoHotkey] 기타 모음 (0) | 2015.03.20 |
[파이션/Python] 기본 정리1 (0) | 2015.03.20 |