Sukriti Singh
Sukriti Singh

Reputation: 53

Is there any way to download csv file from "website button click" using R

download.file(URL, destfile = "../data.csv", method="curl") need exact url of csv but i need to download the CSV file from a website having "Download Click" option. "http://apps.who.int/gho/data/view.main.MHSUICIDEASDRREGv?lang=en" --> Link

Upvotes: 1

Views: 14644

Answers (2)

ASH
ASH

Reputation: 20302

You can hit F12 and see the code behind that page, and pretty much any page, except maybe flash elements. Then, do something like this.

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")

You can find lots and lots of other ideas from the link below.

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

Upvotes: 2

Ayush Nigam
Ayush Nigam

Reputation: 384

copy paste this :

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")

i have used destination file path as "H:/test.csv" you can wherever u want to save the file

Upvotes: 0

Related Questions