AKShare is famous package using Python for fetching data, but now we can use AKTools for AKShare HTTP API Server!

library(RCurl)  # 需要先安装该包
library(jsonlite)  # 需要先安装该包
library(ggplot2)  # 需要先安装该包
options (warn = -1)  # 该行有助于在无参数请求时去掉 warning 信息

temp_df <-
  getForm(
    uri = 'http://127.0.0.1:8080/api/stock_zh_a_hist',  # 此处的 http://127.0.0.1:8080 需要替换为您定义的地址和端口
    symbol = '000001',
    start_date = '20000101',
    end_date = '20211224',
    adjust = 'hfq',
    .encoding = "utf-8"
  )
inner_df <- fromJSON(temp_df)
inner_df = data.frame(inner_df)
inner_df$日期 = as.Date(inner_df$日期)

You can check out data, for example:

head(inner_df)
##         日期   开盘   收盘   最高   最低 成交量    成交额 振幅 涨跌幅 涨跌额
## 1 2000-01-04 576.58 601.56 609.79 567.10  82160 147324992 7.42   4.62  26.56
## 2 2000-01-05 603.46 594.29 619.27 592.39  93993 173475008 4.47  -1.21  -7.27
## 3 2000-01-06 593.03 617.06 625.60 584.49 120222 221192000 6.92   3.83  22.77
## 4 2000-01-07 624.02 641.09 648.36 620.85 229346 443592000 4.46   3.89  24.03
## 5 2000-01-10 649.00 660.06 670.82 648.36 185210 372294016 3.50   2.96  18.97
## 6 2000-01-11 660.38 624.02 661.96 617.69 126663 245867008 6.71  -5.46 -36.04
##   换手率
## 1   0.77
## 2   0.88
## 3   1.12
## 4   2.14
## 5   1.73
## 6   1.18
ggplot(inner_df, aes(x = 日期, y = 收盘)) + geom_line()
plot of chunk unnamed-chunk-3