V
V
vladimir3282020-07-04 17:46:25
Python
vladimir328, 2020-07-04 17:46:25

Why is none displayed instead of degrees?

Why is none displayed instead of degrees?

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)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ScriptKiddo, 2020-07-04
@vladimir328

<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')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question