@vladimir328

Почему вместо градусов выводится none?

Почему вместо градусов выводится none?
import requests
from bs4 import BeautifulSoup
url = 'https://yandex.ru/pogoda/novosibirsk/details?via=mf#4'
page = requests.get(url)
print(page.status_code)

data_dirt = []
weather_dirt = []
when_dirt = []
soup = BeautifulSoup(page.text,'html.parser')


def today(data_dirt,weather_dirt,when_dirt,soup):
    data_dirt = soup.find_all('span',class_='forecast-details__day-name')
    when_dirt = soup.find_all('div',class_='weather-table__daypart')
    weather_dirt = soup.find_all('div',class_='weather-table__temp')

    data = [item.string for item in data_dirt]
    when = [item.string for item in when_dirt]
    weather = [item.string for item in weather_dirt]

    

    print(data + weather)


today(data_dirt,weather_dirt,when_dirt,soup)
  • Вопрос задан
  • 91 просмотр
Решения вопроса 1
ScriptKiddo
@ScriptKiddo
<td class="weather-table__body-cell weather-table__body-cell_type_daypart weather-table__body-cell_wrapper">
                                        <div class="weather-table__wrapper">
                                            <div class="weather-table__daypart">утром</div>
                                            <div class="weather-table__temp">
                                                <div class="temp" role="text"><span class="temp__value">+17</span><span
                                                        class="temp__unit i-font i-font_face_yandex-sans-text-medium">°</span>
                                                </div>&hellip;<div class="temp" role="text"><span class="temp__value">+22</span><span
                                                    class="temp__unit i-font i-font_face_yandex-sans-text-medium">°</span>
                                            </div>
                                            </div>
                                        </div>
                                    </td>


weather_dirt = soup.find_all('span', class_='temp__value')
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

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

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