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()