You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无需RSelenium在R中抓取动态网页:提取加拿大轮胎高息储蓄账户3.5%利率

解决方案

一、用浏览器DevTools定位JSON数据源

  • 打开目标页面,右键选择「检查」打开开发者工具
  • 切换到「Network」标签页,刷新页面
  • 在筛选栏输入json,过滤所有JSON格式的请求
  • 逐个查看返回的JSON内容,找到包含Canadian Tire High Interest Savings® Account及对应利率的条目,你提供的https://www.ctfs.com/content/ctfs3/en.model.json就是目标数据源

二、验证指定JSON是否包含目标利率

运行你给出的代码后,通过str(info)的输出可以定位到目标数据:

  • 3.5%的利率确实存储在这个JSON里,具体路径为info$content$root$children[[1]]$children[[2]]$children[[1]]$children[[1]]$children[[1]]$children[[1]]$children[[1]]$text(页面结构若有更新需微调路径)
  • 直接提取利率的R代码示例:
library(jsonlite)

# 读取JSON数据
info <- read_json("https://www.ctfs.com/content/ctfs3/en.model.json")

# 提取目标利率
target_rate <- info$content$root$children[[1]]$children[[2]]$children[[1]]$children[[1]]$children[[1]]$children[[1]]$children[[1]]$text

# 输出结果
cat("Canadian Tire High Interest Savings® Account的利率:", target_rate, "\n")

三、注意事项

  • 若后续页面结构更新,提取失败时需重新通过Network标签确认JSON数据的结构变化
  • 代码中无需加载tibble和rvest包,仅jsonlite即可完成解析提取

内容的提问来源于stack exchange,提问作者ixodid

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.12 07:16:01