soyizi 发表于 2017-4-24 07:37:38

python http客户端

'''
Created on 2013-3-18

@author: lixuan
'''
# coding=utf-8
import urllib2
response = urllib2.urlopen('http://python.org/')
html = response.read()
print html

req = urllib2.Request('http://www.voidspace.org.uk')
response = urllib2.urlopen(req)
the_page = response.read()


import urllib


url = 'http://music.baidu.com/'
values = {'name' : 'Michael Foord',
          'location' : 'Northampton',
          'language' : 'Python' }

data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
the_page = response.read()
print the_page



if __name__ == '__main__':
    pass
页: [1]
查看完整版本: python http客户端