urlopen
python3 |
python2 |
urllib.request.urlopen |
urllib2.urlopen |
urlretrieve
python3 |
python2 |
urllib.request.urlretrieve |
urllib.urlretrieve |
urlencode参数编码
python3 |
python2 |
urllib.parse.urlencode |
urllib.urlencode |
parse_qs解码
python3 |
python2 |
urllib.parse.parse_qs |
urllib2.urlparse.parse_qs |
urlparse
python3 |
python2 |
urllib.parse.urlparse |
urllib2.urlparse.urlparse |
urllib2.urlparse.urlsplit('http://www.baidu.com/dd?xx=1&yy=2#1')
SplitResult(scheme='http', netloc='www.baidu.com', path='/dd', query='xx=1&yy=2', fragment='1')
ProxyHandler
build_opener
python3 |
python2 |
urllib.request.ProxyHandler |
urllib2.ProxyHandler |
urllib.request.build_opener |
urllib2.build_opener |
handler=urllib2.ProxyHandler({'http':'127.0.0.1:1080'})
opener=urllib2.build_opener(handler)
opener.open('http://httpbin.org/ip').read()
CookieJar
python3 |
python2 |
http.cookiejar.CookieJar |
cookielib.Cookiejar |
cookiejar=CookieJar()
handler=urllib2.HTTPCookieProcessor(cookiejar=cookiejar)
opener=urllib2.build_opener(handler)
MozillaCookieJar
cookiejar=MozillaCookieJar('d:/tmp/cookie.txt')
...
cookiejar.save(ignore_discard=True)
cookiejar.load(ignore_discard=True)