import urllib2
response = urllib2.urlopen('http://www.baidu.com')
html = response.read()
print html
import urllib2
req = urllib2.Request('http://www.baidu.com')
response = urllib2.urlopen(req)
page = response.read()
print page
import urllib
import urllib2
url = 'http://www.someserver.com/register.cgi'
values = {
'name': "Lord",
'location': 'China',
'language': 'Python'
}
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
page = response.read()
import urllib
import urllib2
data = {
'name': 'Lord',
'location': 'China',
'language': 'Python'
}
values = urllib.urlencode(data)
print values
url = 'http://www.example.com/example.cgi'
full_url = url + '?' + values
data = urllib2.urlopen(full_url)
网友评论