title: scheduling scraping/downloading of file from site via RStudio Server on EC2 and RSelenium (?)
body: <p>I would like to schedule daily downloads of a file (which is daily updated) from a <a href="https://www.facebook.com/ads/library/report/" rel="nofollow noreferrer">website</a> (download button at the very end of the page). So far I figured out that one possible avenue is to set up an EC2 instance on Amazon WS which runs RStudio Server (see e.g. <a href="https://towardsdatascience.com/how-to-run-rstudio-on-aws-in-under-3-minutes-for-free-65f8d0b6ccda" rel="nofollow noreferrer">here</a>). Here the script could be triggered by e.g. the <code>cronR</code> package. </p>
  
  <p>I manage to download the file on my local machine with the RSelenium package (below the code). </p>
  
  <pre><code>library(RSelenium)
  
  #open server
  rd &lt;- rsDriver(browser = "firefox", port = 4444L)
  
  #open browser
  ffd &lt;- rd$client
  
  #navigate to target url
  url &lt;- 'https://www.facebook.com/ads/library/report/'
  ffd$navigate(url)
  
  css_selector &lt;- "._7vio"
  download_btn &lt;- ffd$findElement(using = "css selector", css_selector)
  download_btn$clickElement()
  </code></pre>
  
  <p>However, running RSelenium in an AWS instance seems (at least for me) to be a rather intimidating task which I haven't yet figured out (installing a docker image with RSelenium on the EC2..e.g. like <a href="https://stackoverflow.com/questions/53916609/rselenium-and-docker-on-ec2">here</a> or <a href="https://rpubs.com/johndharrison/RSelenium-Docker" rel="nofollow noreferrer">here</a>).</p>
  
  <p>Hence I was wondering whether there isn't an easier way which would allow me to run a simple script in RStudio Server without the need for RSelenium. The challenge I am facing is how to trigger a click on the download button without RSelenium (and Docker etc)? I gather that there might be 'some way' to get the file via a POST request. The developer tools reveal that the click on the download button trigger a POST/GET command, but I am here only poking and not really sure how to proceed.</p>
  
  <p>PS: I know that there is also an facebook API, but the information provided is not identical to the info in the daily reports.</p>