首页 > 解决方案 > 如何使用 R 中的“rusquant”包从investing.com 中抓取信息

问题描述

我之前发布了一个类似的问题[问题现在已关闭,我将其删除]。从那我开始了解'rusquant'包。我感谢在这里向我介绍包裹“rusquant”的人。我在几次尝试从investing.com 抓取股票数据时尝试了以下代码,但均未成功

library(rusquant)
all_stocks <- getSymbolList(src = "Investing", country = "Bangladesh")
head(all_stocks, 4)
from_date <- date("2021-01-01")
grameenphone <- getSymbols('GRAE', src = 'Investing', from = from_date, auto.assign = F)
grameenphone <- getSymbols.Investing('GRAE', from = from_date, auto.assign = F)

现在,getSymbolList 函数起作用了。但是,当我尝试抓取特定股票并遵循https://github.com/arbuzovv/rusquant中的方法时,出现错误。如下:

 grameenphone <- getSymbols('GRAE', src = 'Investing', from = from_date, auto.assign = F)
‘getSymbols’ currently uses auto.assign=TRUE by default, but will
use auto.assign=FALSE in 0.5-0. You will still be able to use
‘loadSymbols’ to automatically load data. getOption("getSymbols.env")
and getOption("getSymbols.auto.assign") will still be checked for
alternate defaults.

This message is shown once per session and may be disabled by setting 
options("getSymbols.warning4.0"=FALSE). See ?getSymbols for details.

Error in curl::curl_fetch_memory(url, handle = handle) : 
  Unrecognized content encoding type. libcurl understands deflate, gzip content encodings.

然后我尝试了 getSymbols.Investing 功能。但我收到以下错误:

grameenphone <- getSymbols.Investing('GRAE', from = from_date, auto.assign = F)
Error in missing(verbose) : 'missing' can only be used for arguments

请帮帮我。我是编码新手。如果这里发生了什么愚蠢的事情,我深表歉意。提前致谢。

标签: rweb-scrapingr-portfolioanalytics

解决方案


推荐阅读