title: How to download multiple files with the same name from html page?
body: <p>I want to download all the files named "listings.csv.gz" which refer to US cities from <a href="http://insideairbnb.com/get-the-data.html" rel="nofollow noreferrer">http://insideairbnb.com/get-the-data.html</a>, I can do it by writing each link but is it possible to do in a loop?</p>
  
  <p>In the end I'll keep only a few columns from each file and merge them into one file.</p>
  
  <p>Since the problem was solved thanks to @CodeNoob I'd like to share how it all worked out:</p>
  
  <pre><code>page &lt;- read_html("http://insideairbnb.com/get-the-data.html")
  
  # Get all hrefs (i.e. all links present on the website)
  links &lt;- page %&gt;%
    html_nodes("a") %&gt;%
    html_attr("href")
  
  # Filter for listings.csv.gz, USA cities, data for March 2019
  wanted &lt;- grep('listings.csv.gz', links)
  USA &lt;- grep('united-states', links)
  wanted.USA = wanted[wanted %in% USA]
  wanted.links &lt;- links[wanted.USA]
  wanted.links = grep('2019-03', wanted.links, value = TRUE)
  
  wanted.cols = c("host_is_superhost", "summary", "host_identity_verified", "street", 
                  "city", "property_type", "room_type", "bathrooms", 
                  "bedrooms", "beds", "price", "security_deposit", "cleaning_fee", 
                  "guests_included", "number_of_reviews", "instant_bookable", 
                  "host_response_rate", "host_neighbourhood", 
                  "review_scores_rating", "review_scores_accuracy","review_scores_cleanliness",
                  "review_scores_checkin" ,"review_scores_communication", 
                  "review_scores_location", "review_scores_value", "space", 
                  "description", "host_id", "state", "latitude", "longitude")
  
  
  read.gz.url &lt;- function(link) {
    con &lt;- gzcon(url(link))
    df  &lt;- read.csv(textConnection(readLines(con)))
    close(con)
    df  &lt;- df %&gt;% select(wanted.cols) %&gt;%
      mutate(source.url = link)
    df
  }
  
  all.df = list()
  for (i in seq_along(wanted.links)) {
    all.df[[i]] = read.gz.url(wanted.links[i])
  }
  
  all.df = map(all.df, as_tibble)
  </code></pre>