@NOblo

Как из html кода получить данные В питоне?

С этого:
<html>
  <head>
    <title>Hello, from tc.inq.com</title>
  </head>
  <body bgcolor=white>

    <p>This is the home page for the inq.com. </p>

  </body>
</html


Получить это то что в <\p>
Чтобы получилось так:
var = "This is the home page for the inq.com."
Как по тегу отследить? Есть какие то приспособления, или нужно использовать find?
  • Вопрос задан
  • 412 просмотров
Решения вопроса 1
SoreMix
@SoreMix Куратор тега Python
yellow
from bs4 import BeautifulSoup
html = '''<html>
  <head>
    <title>Hello, from tc.inq.com</title>
  </head>
  <body bgcolor=white>

    <p>This is the home page for the inq.com. </p>

  </body>
</html'''
soup = BeautifulSoup(html, 'html.parser')
print(soup.find('p').text)
Ответ написан
Комментировать
Пригласить эксперта
Ответы на вопрос 1
netpastor
@netpastor
Python developer
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы