Answer the question
In order to leave comments, you need to log in
Why doesn't bs4 ( BeautifulSoup ) see the [ div class="h1" ] element?
Hello, here is the following:
for example, there is a page:
www.irk.gov.ru/events/news/detail.php?ID=19587
news title - in
<div class="h1">В своих избирательных округах проведут ближайшую неделю депутаты Законодательного Собрания </div>
import requests
from bs4 import BeautifulSoup
import sys, traceback
def main():
try:
r = requests.get('http://www.irk.gov.ru/events/news/detail.php?ID=19587', 'html.parser')
soup = BeautifulSoup(r.content, 'html.parser')
for i in soup.find_all('div', class_="h1"):
title = i.text
print(title) #(если print(i) - то <div class="h1">Просмотр новости</div>)
input()
except Exception:
print(traceback.format_exception(*sys.exc_info())[1])
input("End ")
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question