Python---httplib2

import urllib.request as ur
import http.client as hc
import httplib2
import urllib.parse as up

def httplibtwo1():
    print('===================httplib2========================')
    url='http://www.12306.cn/mormhweb/'
    httplib2.debuglevel=1
    h = httplib2.Http('.cache')
    h.add_credentials('xfei.zhang','11111111')
    print('=================request=========================')
    response, content=h.request(url,'GET',headers={'cache-control':'no-cache'})
    print('\n=================response=======================')
    print(response.items())
    print(response.status)
    print(response.fromcache)
    data={'age':'30','name':'jasca'}
    data2=up.urlencode(data)
    print(data2)

if __name__ == '__main__':
    httplibtwo1()
相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息