r - 抓取数据时包含两个倍数
问题描述
希望从
https://www.wetterzentrale.de/weatherdata.php?station=260&jaar=2019&maand=1&dag=1
从 2019-01-01 到今天,我还不知道如何编写代码更改 jaar=2019(即 year=2019)、maand=1(即 month=1)和 dag=1(即, day=1) 到所需的日期。
我尝试使用 lapply 作为:
years <- c("2019", "2020")
urls <- rbindlist(lapply(years, function(x) {
url <- paste(https://www.wetterzentrale.de/weatherdata.php?station=260&jaar=2019&maand=1&dag=1, sep = "")
data.frame(url)
} ))
因此,这只给出了 2019 年和 2020 年的网址。有没有办法包括月份和日期?
解决方案
library(lubridate)
allYourDates <- seq(ymd(20190101), Sys.Date(), by = "days")
urls <- paste("https://www.wetterzentrale.de/weatherdata.php?station=260&jaar=", year(allYourDates)
, "&maand=", month(allYourDates)
, "&dag=", day(allYourDates)
, sep = "")
推荐阅读
- python - 调用 pa.hdfs.connect 时出现 NoSuchMethodError
- angularjs - angularjs 错误:[$injector:strictdi] 函数($httpProvider)未使用显式注释,无法在严格模式下调用
- c - 如何使用 CRTSCTS 监听串口
- r - 创建函数时无法创建错误语句
- python - Python:从 300 个数据集创建大小为 12 的数据框,使其包含 0:12、1:13、2:14 等
- angular - 从我的自定义中间件返回到角度时,asp .net core api cors 问题
- node.js - TypeError:无法读取未定义的属性“长度”。在节点 js
- javascript - 无法遍历 mxgraph 中的 xml 文件以获取子节点的指定属性值?
- python - AdaBoost 与 SVM 基分类器的执行时间
- php - 在 Laravel 中加入多个模型进行查询的最佳方法是什么