0

I am trying to reproduce the answer to this question: Using R to "click" a download file button on a webpage.

The below code does work and downloads the content of the page:

library(httr)
res <- POST("http://volcano.si.edu/database/search_eruption_results.cfm", 
            body = list(`eruption_category[]` = "Confirmed Eruption", 
                        `country[]` = "Antarctica"), 
            encode = "form")
content(res)

However downloading the excel file (as with clicking "Download Results to Excel" button) with following code does not work. Both the content of the response and the file are empty.
Removing write_disk part doesn't help.

library(httr)
res <- POST("http://volcano.si.edu/database/search_eruption_excel.cfm", 
            body = list(`eruption_category[]` = "Confirmed Eruption", 
                        `country[]` = "Antarctica"), 
            encode = "form",
            write_disk("eruptions.xls"))
content(res) #NULL

What am I missing?

pajonk
  • 499
  • 11
  • 18

0 Answers0