rvest - R Download .csv file tied to input boxes and a "click" button -


i attempting download .csv file https://www.fantasysharks.com/apps/bert/forecasts/projections.php? tied directly input settings (is not static download link) , load r. after drop boxes filled in, have click on download .csv button. found using r "click" download file button on webpage details bit how using post, unable work modifications code. have attempted 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 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 requested resource /apps/bert/forecasts/projections.php not found on t... </body></html> 

here simpler way csv url:

segment <- 596 position <- 1 scoring <- 16 league <- -1 uid <- 4 csv_url <- sprintf("https://www.fantasysharks.com/apps/bert/forecasts/projections.php?csv=1&segment=%s&position=%s&scoring=%s&league=%s&uid=%s",segment,position,scoring,league,uid) res <- read.csv(url(csv_url)) 

first set parameters different variables later use generate download link sprintf. use url function download file generated url , read file read.csv.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -