I am attempting to download a .csv file from https://www.fantasysharks.com/apps/bert/forecasts/projections.php? that is tied directly the input settings (is not a static download link) and load it into R. After the drop boxes are filled in, you then have to click on the download .csv button. I found this Using R to "click" a download file button on a webpage that details a bit how to do it using POST, but am unable to get it to work with some modifications to that code. I have attempted this code:
library(httr)
library(rvest)
library(purrr)
library(dplyr)
POST("https://www.fantasysharks.com/apps/bert/forecasts/projections.php",
body = list('League'=-1, 'Position'=1, 'scoring'=16, 'Segment'=596, 'uid'=4),
encode = "form") -> res
res
but coming up with the error:
Response [https://www.fantasysharks.com/apps/bert/forecasts/projections.php]
Date: 2017-09-10 15:44
Status: 406
Content-Type: text/html; charset=iso-8859-1
Size: 286 B
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>406 Not Acceptable</title>
</head><body>
<h1>Not Acceptable</h1>
<p>An appropriate representation of the requested resource /apps/bert/forecasts/projections.php could not be found on t...
</body></html>