用户可能知道 R 但需要运行以下 python 代码
import requests
import json
query = "asthma"
r = requests.post("https://ndar.nih.gov/api/search/nda_sw_removal/collection/full", query)
collections = json.loads(r.text)
collections
使用 R 库,如何在 R 中重写 request.post 调用? 挑战在于 python 究竟如何处理 query 参数。
请您参考如下方法:
我猜你正在寻找类似 httr 的东西:
取自 here 的示例:
b2 <- "http://httpbin.org/post"
POST(b2, body = "A simple text string")
另一个例子取自 here :
r <- POST("http://httpbin.org/post", body = list(a = 1, b = 2, c = 3))
根据 Slam 在评论中的建议:
