The Requests Library
The requests
library is a popular Python library for making HTTP requests. It allows you to send HTTP requests to a website's server and retrieve the server's response.
In the context of web scraping, the requests
library can be used to send an HTTP request to a website's server to retrieve the HTML content of a webpage. This is often the first step in the web scraping process, as the HTML content contains all the data that you want to extract.
Tarea
Swipe to start coding
- Import the
requests
library. - Use the
requests
library to retrieve the content of the website (url
). - Save the text (the
.text
attribute) in anhtml
variable.
Once you've completed this task, click the button above the code to check your solution.
Solución
9
1
2
3
4
5
import requests
url = "https://www.scrapethissite.com/pages/simple/"
response = requests.get(url)
html = response.text
Mark tasks as Completed
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 1. Capítulo 2
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla