사내 proxy를 통과하여 웹페이지를 받아오고자 할 때, urllib2의 ProxyHandler를 설정한다.
아래는 proxy 주소가 123.100.20.30:8080 인 경우 이다.
proxy = urllib2.ProxyHandler({'http': '123.100.20.30:8080', 'https': '123.100.20.30:8080'})
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
conn = urllib2.urlopen(addr)
print conn.read()
'Data/Text/Knowledge Analysis & Mining > Python' 카테고리의 다른 글
'쿵푸 팬더'의 사부는 너구리 ? (0) | 2013.06.26 |
---|---|
[python] gzip, bzip 파일 부분 해제 (0) | 2013.04.23 |
[python] gzip 압축 파일 읽기/쓰기 (utf-8 인코딩) (0) | 2013.03.22 |
[python] 나눗셈 구현 (divide operator with bit-operations) (0) | 2013.03.22 |
Damerau-Levenshtein Distance (Edit distance) 구하기 (0) | 2013.03.18 |
WRITTEN BY
- manager@
Data Analysis, Text/Knowledge Mining, Python, Cloud Computing, Platform
,