Друг сделал парсер у него все работает, у меня выдает ошибку. lxml установил, все установил и все тоже самое

from unittest import result import requests from bs4 import BeautifulSoup as bs import json import datetime import os import re

url = 'https://www.gismeteo.ru/weather-moscow-4368/' url_prognos_10days = 'https://www.gismeteo.ru/weather-moscow-4368/10-days/'

def pogoda_msk_today():

response = requests.get(url, headers={"User-Agent" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"})
soap = bs(response.text, 'lxml')

data_temperature = []
temperature = soap.find_all('span', class_ = 'unit unit_temperature_c')
count = 0
for i in temperature:
    count += 1
    if count >= 7:
        data_temperature.append(i.text)
        

data_precipitation = []
precipitation = soap.find_all('div', class_ = 'row-item')
count5 = 0
for q in precipitation:
    count5 += 1
    if count5 in range(25, 33):
        data_precipitation.append(q.text)

data_wind = []
wind = soap.find_all('div', class_ = 'row-item')
count1 = 0
for k in wind:
    count1 += 1
    if count1 in range(49, 57):
        data_wind.append(k.text)

data_atmo_pressure = []
atmospheric_pressure = soap.find_all('span', class_ = 'unit unit_pressure_mm_hg_atm')
count2 = 0
for m in atmospheric_pressure:
    count2 += 1
    if count2 > 1:
        data_atmo_pressure.append(m.text)

data_humidity = []
humidity = soap.find('div', class_ = 'widget-row widget-row-humidity').text
b = re.findall(r'\d\d', humidity)
for tt in b:
    data_humidity.append(tt)


data_msk = {'temperature' : data_temperature, 'precipitation' : data_precipitation, 'wind' : data_wind, 'atmospheric_pressure' : data_atmo_pressure, 'humidity' : data_humidity}
with open('data_pogoda', 'w', encoding = 'utf-8') as f: 
    f.write(json.dumps(data_msk, ensure_ascii = False, indent = 4))

def prognos(): response = requests.get(url_prognos_10days, headers={"User-Agent" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"}) soap = bs(response.text, 'lxml')

data_temperature_10days = []
temperature = soap.find_all('span', class_ = 'unit unit_temperature_c')
count = 0
a = 0
for i in temperature:
    count += 1
    if count in range(21, 31):
        future_date = datetime.date.today() + datetime.timedelta(days=a)
        data_temperature_10days.append(i.text)
        # print(future_date, 'Температура :', i.text)
        a += 1

data_wind_10days = []
wind = soap.find_all('div', class_ = 'direction')
count = 0
a = 0
for l in wind:
    future_date = datetime.date.today() + datetime.timedelta(days=a)
    data_wind_10days.append(l.text)
    # print(future_date, 'Направление ветра :', l.text)
    a += 1

data_atmospheric_pressure_10days = []
atmospheric_pressure = soap.find_all('span', class_ = 'unit unit_pressure_mm_hg_atm')
count = 0
a = 0
for z in atmospheric_pressure:
    count += 2
    if count in range(3, 21):
        future_date = datetime.date.today() + datetime.timedelta(days=a)
        # print(future_date, 'Атомсферное давление :', z.text)
        data_atmospheric_pressure_10days.append(z.text)
        a += 1

data_precipitation_10days = []
precipitation = soap.find_all('div', class_ = 'item-unit')
for k in wind:
    future_date = datetime.date.today() + datetime.timedelta(days=a)
    data_precipitation_10days.append(k.text)
    
data_humidity_10days = []
humidity = soap.find('div', class_ = 'widget-row widget-row-humidity').text
b = re.findall(r'\d\d', humidity)
for tt in b:
    data_humidity_10days.append(tt)

data_msk_10days = {'temperature' : data_temperature_10days, 'precipitation' : data_precipitation_10days, 'wind' : data_wind_10days, 'atmospheric_pressure' : data_atmospheric_pressure_10days, 'humidity' : data_humidity_10days}
with open('data_pogoda_10days', 'w', encoding = 'utf-8') as f: 
    f.write(json.dumps(data_msk_10days, ensure_ascii = False, indent = 4))

pogoda_msk_today() prognos()

Ошибка:

C:\Users\MangoVirus\AppData\Local\Programs\Python\Python310\python.exe C:/Users/MangoVirus/PycharmProjects/pythonProject/19.py

Traceback (most recent call last):

File "C:\Users\MangoVirus\PycharmProjects\pythonProject\19.py", line 117, in pogoda_msk_today()

File "C:\Users\MangoVirus\PycharmProjects\pythonProject\19.py", line 17, in pogoda_msk_today soap = bs(response.text, 'lxml')

File "C:\Users\MangoVirus\AppData\Local\Programs\Python\Python310\lib\site-packages\bs4_init_.py", line 248, in init

raise FeatureNotFound(

bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?


Ответы (0 шт):