Session Ready
Exercise

Build a function

You're still trying to perfect your tools for doing webs scraping to be as efficient as possible doing your job as a data analyst for a web agency.

In this exercise, you will make the extractor function from the previous exercise a little bit stricter: if the code returned by the status extractor is not between 200 and 203, the function will return a missing value (NA). In the other case, the status code will be returned.

purrr and httr have been loaded for you.

Instructions
100 XP
  • Negate the %in% operator, which is used to test if the element on the left is inside the element of the right.

  • Compose a extract_status() function, which will be a combination of GET() and status_code().

  • Complete the given function: the url status code should be extracted and assigned to a code variable. Then if this code is not in 200:203, a missing value will be returned. Otherwise, the status code is returned.