我正在尝试通过R.
以编程方式下载Clinical Lab Fee Schedule from Medicarelibrary("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)
警告消息:在解压缩(temp,CLAB_FileName)时:提取错误1 来自zip文件
CLAB <- read_excel(CLAB_FileName,skip=1, col_names=TRUE)
read_fun出错(path = path,sheet = sheet,limits = limits,shim = 垫片:评估错误:路径1 =“CLAB2018v1.xls”:系统 找不到指定的文件。
答案 0 :(得分:1)