#Read in webpage to get file names to download library(rvest) url<-"https://s3.amazonaws.com/tripdata/index.html" page <- read_html(url) temp<-html_text(html_nodes(page, "a")) df<-as.data.frame(temp) #Using download.file to get file #create a temporary file temp <- tempfile() download.file("https://s3.amazonaws.com/tripdata/201603-citibike-tripdata.zip",temp,mode="wb") temp1 <- unzip(temp, "201603-citibike-tripdata.csv") df <- read.csv(temp1, header=T, sep=",") unlink(temp) #Reading in zip file that contians several files df=data.frame() zipdir <- tempfile() dir.create(zipdir) download.file("https://www.ssa.gov/oact/babynames/state/namesbystate.zip", temp, mode="wb") unzip(temp, exdir=zipdir) files <- list.files(zipdir, pattern="\\.TXT$") df<-data.frame() for(i in 1:length(files)){ filepath <- file.path(zipdir,files[i]) temp <- read.csv(filepath,header=F) df<-rbind(df, temp) } unlink(zipdir)