【发布时间】:2018-03-07 23:30:50
【问题描述】:
我正在尝试通过 R 以编程方式下载 Clinical Lab Fee Schedule from Medicare。
library("readxl")
ZIPURL <- "https://www.cms.gov/apps/ama/license.asp?file=/Medicare/Medicare-Fee-for-Service-Payment/ClinicalLabFeeSched/Downloads/18CLAB.zip"
CLAB_FileName <- "CLAB2018v1.xls"
temp <- tempfile()
download.file( ZIPURL,temp, mode="wb")
con <- unzip(temp, CLAB_FileName)
CLAB <- read_excel(CLAB_FileName,skip=1, col_names=TRUE)
unlink(temp)
要下载 ZIP 文件,网站要求用户单击“接受”按钮。此验证步骤似乎会干扰download.file(),因此代码会改为下载 html 页面。 R 中是否有选项或额外功能可以绕过或输入验证?
我从命令中看到的响应是:
download.file( ZIPURL,temp, mode="wb")
尝试网址 'http://www.cms.gov/apps/ama/license.asp?file=/Medicare/Medicare-Fee-for-Service-Payment/ClinicalLabFeeSched/Downloads/18CLAB.zip' 内容类型 'text/html' 长度 42502 字节 (41 KB) 已下载 41 KB
con <- unzip(temp, CLAB_FileName)
警告消息:在 unzip(temp, CLAB_FileName) 中:提取时出现错误 1 来自压缩文件
CLAB <- read_excel(CLAB_FileName,skip=1, col_names=TRUE)
read_fun 中的错误(路径 = 路径,工作表 = 工作表,限制 = 限制,垫片 = shim,:评估错误:path1="CLAB2018v1.xls":系统 找不到指定的文件。
【问题讨论】:
-
我不确定我是否理解这有什么帮助。
-
抓取页面是违法的。
-
感谢您分享robot.txt,我以前从未见过,并且学到了一些新东西。看起来@Level 3 Helmet 提供的文件路径是不允许的,所以下载我说的文件应该是合法的。
标签: r download verification