wiscostret / fplscrapR

This package enables those interested in Fantasy Premier League to perform detailed data analysis of the game, using the FPL's JSON API. The fplscrapR functions help R users collect and parse data from the Official Fantasy Premier League website.
Creative Commons Zero v1.0 Universal
76 stars 16 forks source link

Error in open.connection(con, "rb") #27

Open ciya2326 opened 2 years ago

ciya2326 commented 2 years ago

Hello.

I am currently working on a project that has an optimal selection of FPL players and has been using the fplscrapR package. It is great and allows easy access to data. I'm trying to use it to get the player's score for each game week for the last three years, but I'm having some problems trying to understand how to use the function and run an example of it.

get_entry_player_picks(1076,1) Error in open.connection(con, "rb") : HTTP error 404.

(Articles: https://wiscostret.github.io/fplscrapR/articles/hazalexishist.html)

df <- get_player_hist ( playerid = get_player_id ( c ( "Mesut Özil" , "Juan Mata" ))$ id ) Error in open.connection(con, "rb") : cannot open the connection In addition: Warning message: In open.connection(con, "rb") : cannot open URL 'https://fantasy.premierleague.com/api/element-summary/NA/': HTTP status was '404 Not Found'

I initially thought the problem was on my computer and tried turning off the windows firewall, but I still can't get the data. Has anyone else had the same problem recently? If you have any time to get back to me I would be very grateful.

wiscostret commented 2 years ago

Hi there,

I will update some of the vignettes, hopefully before the season starts, because I can see how they may cause confusion like here.

Simply, the errors you get are because:

1) get_entry_player_picks() won't work before Gameweek 1. This function fetches player picks for a given entry (team). But since the season hasn't started, there aren't any player picks. So you'll have to wait for Gameweek 1.

2) get_player_hist() only works for players currently in the game. If you run get_player_hist(playerid = get_player_id("Mohamed Salah")$id), that will work. You can access data from prior season through several package functions, e.g. get_player_info() or get_player_details() by specifying the 'season' parameter.