首页 文章

有没有办法从使用R的“网站按钮点击”下载csv文件

提问于
浏览
1

download.file(URL, destfile = "../data.csv", method="curl") 需要csv的确切网址,但我需要从“下载点击" option. " http://apps.who.int/gho/data/view.main.MHSUICIDEASDRREGv?lang=en” - >链接的网站下载CSV文件

2 回答

  • 2

    复制贴这个:

    download.file(url = "http://apps.who.int/gho/athena/data/GHO/MH_12?filter=COUNTRY:-;REGION:*&x-sideaxis=REGION;SEX&x-topaxis=GHO;YEAR&profile=crosstable&format=csv", destfile = "H:/test.csv")
    

    我已经使用目标文件路径作为“H:/test.csv”,您可以在任何地方保存文件

  • 0

    您可以点击F12并查看该页面后面的代码,几乎任何页面,除了flash元素 . 然后,做这样的事情 .

    getit <- read.csv("http://apps.who.int/gho/athena/data/GHO/MH_12?filter=COUNTRY:-;REGION:*&x-sideaxis=REGION;SEX&x-topaxis=GHO;YEAR&profile=crosstable&format=csv")
    head(getit)
    
    getit <- fread("http://apps.who.int/gho/athena/data/GHO/MH_12?filter=COUNTRY:-;REGION:*&x-sideaxis=REGION;SEX&x-topaxis=GHO;YEAR&profile=crosstable&format=csv")
    
    getit <- read_csv("http://apps.who.int/gho/athena/data/GHO/MH_12?filter=COUNTRY:-;REGION:*&x-sideaxis=REGION;SEX&x-topaxis=GHO;YEAR&profile=crosstable&format=csv")
    

    您可以从以下链接中找到许多其他想法 .

    https://www.datacamp.com/community/tutorials/r-data-import-tutorial

相关问题