Giter Club home page Giter Club logo

Comments (3)

jthomasmock avatar jthomasmock commented on June 12, 2024 1

Hi @IvoVillanueva , I've gone ahead and revamped all the functions to use httr proper so that it avoids the 503 errors.

get_nfl_teams() works again!

get_nfl_teams()
Getting NFL teams!
# A tibble: 32 x 8
   team_id team_name team_nickname team_abb team_full_name     team_color
   <chr>   <chr>     <chr>         <chr>    <chr>              <chr>     
 1 22      Cardinals Arizona       ARI      Arizona Cardinals  #A40227   
 2 1       Falcons   Atlanta       ATL      Atlanta Falcons    #000000   
 3 33      Ravens    Baltimore     BAL      Baltimore Ravens   #2B025B   
 4 2       Bills     Buffalo       BUF      Buffalo Bills      #04407F   
 5 29      Panthers  Carolina      CAR      Carolina Panthers  #2177B0   
 6 3       Bears     Chicago       CHI      Chicago Bears      #152644   
 7 4       Bengals   Cincinnati    CIN      Cincinnati Bengals #FF2700   
 8 5       Browns    Cleveland     CLE      Cleveland Browns   #4C230E   
 9 6       Cowboys   Dallas        DAL      Dallas Cowboys     #002E4D   
10 7       Broncos   Denver        DEN      Denver Broncos     #002E4D   
# … with 22 more rows, and 2 more variables: team_alt_color <chr>,
#   logo <chr>

from espnscraper.

jthomasmock avatar jthomasmock commented on June 12, 2024

Howdy! I'm going to have to refactor to httr::GET() calls, thanks for heads up. The behavior is more consistent that way.

from espnscraper.

IvoVillanueva avatar IvoVillanueva commented on June 12, 2024

Hi Tom
With your permission I propose this code change so that the function works.
(sorry for my English)

 get_nfl_teams <- function() {
   message("Getting NFL teams!")
   
   team_url <- "https://site.api.espn.com/apis/site/v2/sports/football/nfl/teams?&limit=50"
   raw_teams <- jsonlite::read_json(team_url)
   
     raw_teams$sports[[1]]$leagues[[1]]$teams%>%
     tibble::enframe() %>% 
     dplyr::select(-name) %>% 
     tidyr::unnest_wider(value) %>%
     tidyr::unnest_wider(team) %>% 
     dplyr::select(-links) %>%
     dplyr::as_tibble()  %>% 
     dplyr::mutate("logoDefault" = purrr::map_chr(logos, function(df) df[[1]][[1]]),
                   "logoDark" = purrr::map_chr(logos, function(df) df[[2]][[1]]),
                   "logoScoreboard" = purrr::map_chr(logos, function(df) df[[3]][[1]]),
                   "logoDarkScoreboard" = purrr::map_chr(logos, function(df) df[[4]][[1]])) %>% 
     dplyr::select(id, name:alternateColor,-shortDisplayName, logoDefault:logoDarkScoreboard) %>% 
     purrr::set_names(
       nm = c(
         "uid", "team_name", "team_nickname", "team_short_name", "full_name", "team_color",
         "alternate_color", "logodefault", "logodark", "logoscoreboard", "logodarkscoreboard"
       )) %>% 
     dplyr::mutate(
       team_color = paste0("#", team_color),
       alternate_color = paste0("#", alternate_color)
     )

 %>%
     dplyr::mutate(
       team_color = paste0("#", team_color),
       alternate_color = paste0("#", alternate_color)
     )
 }

I hope you do not mind

from espnscraper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.