1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
| import http.client, urllib.parse
def httpGet(url):
conn = http.client.HTTPSConnection(url)
conn.request("GET", "/")
rv = conn.getresponse()
data = None
if rv.status == 200 or rv.reason == "OK":
data = rv.read()
return rv, data
def httpProxyGet(proxyaddr, proxyport, url):
conn = http.client.HTTPSConnection(proxyaddr, proxyport)
conn.set_tunnel(url)
conn.request("GET", "/")
rv = conn.getresponse()
data = None
if rv.status == 200 or rv.reason == "OK":
data = rv.read()
conn.close()
return rv, data
def httpGetTest():
rv, data = httpGet("www.python.org")
print( data )
print( rv.status, rv.reason )
if __name__ == "__main__":
httpGetTest()
|
댓글 없음:
댓글 쓰기