+ 1
Help with Python 'requests' library?
I'm just getting to know the requests library and I'm trying to figure out how to get raw data from a url? For example if I were to put in the URL of a news articles it would return raw text of all the text in the news article and in the website? Is this possible?
2 Respostas
+ 2
import requests
url = 'https://example.com' # Reemplaza con la URL del artículo
response = requests.get(url)
if response.status_code == 200:
raw_text = response.text
print(raw_text) # Esto imprimirá el HTML sin procesar
else:
print(f'Error al acceder a la URL: {response.status_code}')
+ 1
Yup, it's possible, and you might also want to use the BeautifulSoup library too