<jupyter_start><jupyter_text>Parseando HTML con BeautifulSoup<jupyter_code>import requests
from bs4 import BeautifulSoup
url = 'https://www.pagina12.com.ar/'
p12 = requests.get(url)
p12.status_code<jupyter_output><empty_output><jupyter_text>BeautifulSoup lo que hará es parsear el documento HTML guardado en la variable p12, y nos permitirá identificar partes de interés de él.<jupyter_code>sopa = BeautifulSoup(p12.text, 'lxml')
type(sopa)
print(sopa.prettify())
sopa.find('ul')
sopa.find('ul', attrs={'class':'hot-sections'}).find_all('li')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12937062937062938, 'fraction_numerical': 0.019230769230769232, 'mean_word_length': 8.39344262295082, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '397254', 'license': 'MIT', 'n_tokens_mistral': 227, 'n_tokens_neox': 215, 'n_words': 43, 'path': 'scripts/1-html-request-beafutifulsoup/2-parseando-html-beautifulsoup/parseando-html-beautifulsoup.ipynb', 'repo_name': 'OscarPalominoC/CursoWebScrapingExtraccionDatosWeb', 'size': '572'}