import requests
import json
url = 'https://fanyi.baidu.com/sug'
headers = {
'User-Agent': '',
'Cookie': ''
}
data = {
'kw': 'hello'
}
response = requests.post(url, data, headers=headers)
content = response.text
obj = json.loads(content.encode('utf-8'))
print(obj)
总结:
- post请求不需要编解码
- post请求的参数是data
- 不需要请求对象的定制