urllib 网址编码
导入模块1 urlencode 和 urlopen,Request
三步走1拼接 2封装 3请求
from urllib.parse import urlencode
from urllib.request import urlopen,Request
url = 'https://www.baidu.com/s?'
uc = urlencode({'wd':'美女'})
#拼接编码
url = url +uc
#封装
req = Request(url=url)
#请求
res = urlopen(req)
#读取并解码
html = res.read().decode('utf-8')
print(html)