'''
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
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
本文提供了使用Python进行网络请求的基本示例,包括如何利用urllib2模块从不同网站获取页面内容。
2742

被折叠的 条评论
为什么被折叠?



