使用urllib3的簡單記錄

import urllib3
http = urllib3.PoolManager()
r = http.request('GET', 'http://www.baidu.com/')
r.status
print(r.data)


fields = {
    'foo': 'bar',
    'fakefile': ('foofile.txt', 'contents of foofile'),
    'file': ('barfile.txt', open("/Users/toriycn/Documents/log").read()),
    'typedfile': ('bazfile.bin', open("/Users/toriycn/Documents/log").read(),
                  'image/jpeg'),
    'nonamefile': 'contents of nonamefile field',
}
r = http.request_encode_body('POST','127.0.0.1:7259/upload',fields,None,True)
print(r.status)
python使用urllib3的一個簡單的記錄。
相關文章
相關標籤/搜索