import json
import requests
##以翻译hello为例
###输入查询词,在header处显示的是post方式访问,访问的链接是https://fanyi.baidu.com/sug,response时数据是json格式content-type: application/json,输入的值是kw: hell
url="https://fanyi.baidu.com/sug"
data={'kw':'hello'}
resp=requests.post(url,data=data)
html=resp.content.decode('utf-8')
myjson=json.loads(html)
print(myjson)
print(myjson['data'][0]['v'])
requests案例实战:post方式使用百度翻译
最新推荐文章于 2024-04-22 12:03:40 发布