У меня есть базовый c запрос веб-сайта о погоде, как показано ниже:
import requests, bs4, lxml
url = ('https://forecast.weather.gov/MapClick.php?..')
page = requests.get(url)
soup = bs4.BeautifulSoup(page.content, 'lxml')
Большой раздел с классом и идентификатором содержит информацию, которую я ищу. Я вытащил это с помощью приведенного ниже
weather = soup.find(id='detailed-forecast-body')
Вот пример print (weather.prettify())
<div class="panel-body" id="detailed-forecast-body">
<div class="row row-odd row-forecast">
<div class="col-sm-2 forecast-label">
<b>
Today
</b>
</div>
<div class="col-sm-10 forecast-text">
A slight chance of showers before 9am, then a slight chance of showers and thunderstorms after 3pm. Mostly sunny, with a high near 68. Breezy, with a north wind 8 to 13 mph increasing to 15 to 20 mph in the afternoon. Winds could gust as high as 30 mph. Chance of precipitation is 20%.
</div>
</div>
<div class="row row-even row-forecast">
<div class="col-sm-2 forecast-label">
<b>
Tonight
</b>
</div>
<div class="col-sm-10 forecast-text">
Mostly clear, with a low around 40. North wind 9 to 14 mph becoming light and variable. Winds could gust as high as 21 mph.
Если я хочу извлечь текст из слова «Сегодня вечером», если я вытащить его из погодного объекта, который я создал? ИЛИ я должен работать с созданным суповым объектом?
Как создать условие для извлечения текста только из сегодняшнего вечера?
Спасибо, Шон