将 curl 命令放入 R 脚本并将输出捕获到变量

Putting a curl command into a R script and capturing the output to a variable

我需要在 R 脚本中使用以下 bash 命令(或等效命令)。理想情况下,我需要将输出捕获到一个变量中

curl -LH“接受:text/bibliography;样式=bibtex”https://doi.org/10.1002/cbin.11105

我检查了 httr 库,但我没有运气。此外,我尝试将命令嵌入到系统调用中,但使用“intern = TRUE”选项很难解析输出。 提前致谢

library(httr)
res <- GET("https://doi.org/10.1002/cbin.11105", accept("text/bibliography; style=bibtex"))
res
# Response [https://api.crossref.org/v1/works/10.1002%2Fcbin.11105/transform]
#   Date: 2022-03-18 19:21
#   Status: 200
#   Content-Type: text/bibliography
#   Size: 475 B
#  @article{2019, title={Silencing of MEG3 inhibited ox-LDL-induced inflammation and apoptosis in macrophages via ...

(注意 Status: 200 以确保成功。)

content(res)
# No encoding supplied: defaulting to UTF-8.
# [1] " @article{2019, title={Silencing of MEG3 inhibited ox-LDL-induced inflammation and apoptosis in macrophages via modulation of the MEG3/miR-204/CDKN2A regulatory axis}, volume={43}, ISSN={1095-8355}, url={http://dx.doi.org/10.1002/cbin.11105}, DOI={10.1002/cbin.11105}, number={4}, journal={Cell Biology International}, publisher={Wiley}, author={Yan, Long and Liu, Zhanchuan and Yin, Haoyuan and Guo, Zhenjie and Luo, Qi}, year={2019}, month={Feb}, pages={409?420} }\n"