【发布时间】:2020-05-27 16:49:20
【问题描述】:
我有一个 curl 命令。我想在 Python 中执行并获取响应以将其传递给其他代码。
curl https://api.box.com/oauth2/token -d 'grant_type=refresh_token' -d 'refresh_token=Ew38UXVKS3kc0axFt6MdDklUnoHpipxTzDWBmKlXAG9ImvGafbbaUhQndv89e677' -d 'client_id=3qkm5h4wh765b3khiws0z8hdpkc56jhs' -d 'client_secret=h9AeXzZL3KATJuaHmimFFBRBDZQrp9tr' -X POST
如何在 Python 中执行脚本并获取响应并通过其他代码传递?
当我在 CMD 中执行 curl 脚本时,我收到以下响应:
{"access_token":"uz843jpIiEWnu0CcuT9as2XbA3UEQTR67","expires_in":4261,"restricted_to":[],"refresh_token":"GsDaP6VyUpHN8vDHbz9ktAjLfMLN0dFL6PMIK4fmDH8eKRqR360vDhQTBhIMZxy67","token_type":"bearer"}
从上面的回复中,我需要获取access_token 的值。
【问题讨论】:
标签: python-3.x curl libcurl pycurl shlex