r - 如何从强制下载的链接下载文件
问题描述
使用 R,我想从该站点获取 .csv:https ://vacationwithoutacar.com/gvrat-tracking/但没有与下载相关的链接,它只是自动弹出。通常,我会使用httr
下载,但是当我右键单击该链接时,它不会给我复制 URL 的选项。没有太多可重复的示例,因为我什至无法下载文件。
GET("https://vacationwithoutacar.com/gvrat-tracking/",
write_disk("gvrat.txt",
overwrite = TRUE)
)
解决方案
这似乎工作......
我在 chrome 中打开 URL,按 F12,点击网络,垃圾箱清除,重新加载页面。然后寻找一些下载数据的请求。我看到下面的 URL 返回了 JSON。
library(jsonlite)
df <- fromJSON("https://vacationwithoutacar.com/wp-admin/admin-ajax.php?action=wp_ajax_ninja_tables_public_action&table_id=2596&target_action=get-all-data&default_sorting=old_first")
> head(df)
pos bib participantsname event home g a miles km yourapproximatelocation comp projfin 51 52 53 54
1 1 17395 Gingerbread Man GVRAT US-TN M 145 275.6 443.5 Cowley Hollow 43.50% tbd 83 43 49 52
2 2 1074 Terri Biloski GVRAT CA-ON F 44 274.6 442.0 Cowley Hollow 43.30% tbd 63 59 52 52
3 3 1429 Dave Proctor GVRAT CA-AB M 39 255.3 410.8 Cowley Hollow 40.30% tbd 62 62 5 62
4 4 743 John Sharp GVRAT US-TX M 42 235.0 378.2 Reed Hollow 37.10% tbd 34 41 46 54
5 5 386 Roc Powell GVRAT US-OH M 60 226.0 363.7 Britton Hollow 35.60% tbd 35 75 63 43
6 6 322 Rob Donkersloot GVRAT AU M 60 190.7 306.9 past Deerfield 30.10% tbd 42 42 43 32
55 56 57 58 59 51_1
1 48
2 48
3 63
4 60
5 10
6 32
推荐阅读
- r - 将数据框导出到 R 中的文本文件
- python - ImportError:在 ImageAI 视频对象检测期间无法从“keras.utils.generic_utils”导入名称“LazyLoader”
- javascript - 如何解决自定义元素错误,当我尝试在 vue.js 中的组件之间切换时出现此错误?
- python - 无法在 Python 中解析 XML 文件 - xml.etree.ElementTree.ParseError
- android - 了解垃圾收集器日志颤动
- angular - 如何在 Keycloak Angular 的新选项卡中打开帐户管理
- pdf - 如何从pdf中提取部分并将它们合并为一个pdf
- python - 按 ID 有效地将数据结构化为系列
- javascript - 增加通知显示间隔
- python - 从 gmail api 对象获取用户个人资料照片