1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Functional Programming with purrr

Exercise

Back to the office

You are still working as a data analyst for a web agency, and you've been asked to do web scraping. You have been given a list of URLs to analyze, an analysis you've already started in the previous chapter.

You expect this task to be recurrent: no doubt you'll be asked to do it again in a few weeks. In order to make your future work easier, you've decided to try and write clean code today, so that it will be easier to come back to it later.

We'll start by combining the two functions from httr we've seen in the previous chapter: GET(), for retrieving the webpage, and status_code(), to extract the status code, in order to create a status code extractor.

The urls vector is still available in your workspace. We have kept only the URLs that are reachable.

Instructions

100 XP
  • Launch purrr and httr.

  • Compose a status extractor with GET() and status_code().

  • Try this new function on "https://www.thinkr.fr" and "https://en.wikipedia.org".

  • Map this function directly on the vector urls.