S
S
Senya42021-09-26 19:45:21
Python
Senya4, 2021-09-26 19:45:21

Error when starting from the console, how to solve?

Good evening,

when starting the program from cmd, the following error is displayed: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

But if you run through Pycharm, then there is no error and everything is parsed well.
What to do?

import requests

from bs4 import BeautifulSoup as Bs


def printLines(len, symbol: str):
    print(symbol * len, '>')


url = "https://ekodom64.ru/collection/santehnika"
response = requests.get(url)
soup = Bs(response.text, 'lxml')  # Ошибка

quotes = soup.find_all('div', class_='subcollection-list__item-title')

for quote in quotes:
    text = quote.text.replace('\n', '').strip()
    printLines(21, '-')
    print("Сантехника:", text)
printLines(21, '-')

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Karbivnichy, 2021-09-26
@senya4

Replace lxml with inline html.parser

M
Marat Nagayev, 2021-09-26
@nagayev

You should always read the text of the error.
You are told that you need to install the lxml module,
this can be done like this:
pip install lxml

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question