Код: Выделить всё
import requests
from bs4 import BeautifulSoup
# Send a GET request to the page
url = "https://www.eloratings.net/1999"
response = requests.get(url)
# Parse the content with BeautifulSoup
soup = BeautifulSoup(response.content, 'html.parser')
# Find the main div containing the h1 tag
main_div = soup.find('div', id='main')
# Check if main_div is found
if main_div:
h1_tag = main_div.find('h1')
if h1_tag:
# Print the complete content of the h1 tag
print(f"Vollständiger Inhalt des h1-Tags: {h1_tag.get_text()}")
else:
print("Kein h1-Tag gefunden.")
else:
print("Kein div mit der ID 'main' gefunden.")
< pre class="lang-py Prettyprint-override">
Код: Выделить всё
main_div = soup.find('div', id='main')
if main_div:
h1_tag = main_div.find('h1')
if h1_tag:
print(f"Vollständiger Inhalt des h1-Tags: {h1_tag.get_text()}")
Подробнее здесь: https://stackoverflow.com/questions/793 ... utifulsoup
Мобильная версия