Add a custom user agent
Actually, there's also a httpbin.org address that only returns the current user agent (https://httpbin.org/user-agent). You'll use this for the current exercise, where you'll manipulate your own user agent to turn it into something meaningful (for the owners of the website you're scraping, that is).
As you saw in the video, there are two ways of customizing your user agent when using httr
for fetching web resources:
- Locally, i.e. as an argument to the current request method.
- Globally via
set_config()
.
Cet exercice fait partie du cours
Web Scraping in R
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Pass a custom user agent to a GET query to the mentioned URL
response <- ___
# Print the response content
___(response)