import urllib
url='https://blog.csdn.net/GrofChen/article/details/91492052'
headers={'User-Agent':'Mozilla/5.0 (Window NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36'}
request=urllib.request.Request(url,headers=headers)
response=urllib.request.urlopen(request)
html=response.read().decode('UTF-8')
print(html)
import urllib
url='http://www.baidu.com/s'
word={'wd':'传智播客'}
word=urllib.parse.urlencode(word)
new_url=url+'?'+word
headers={'User-Agent':'Mozilla/5.0 (Window NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36'}
request=urllib.request.Request(new_url,headers=headers)
response=urllib.request.urlopen(request)
html=response.read().decode('UTF-8')
print(html)
import urllib
data={'a':'我','b':'你'}
res=urllib.parse.urlencode(data)
print(res)
rep=urllib.parse.unquote(res)
print(rep)
import urllib
req=urllib.request.Request('http://www.baidu.cn')
res=urllib.request.urlopen(req)
html=res.read().decode('UTF-8')
print(html)