Найти - Пользователи
Полная версия: парсер сайта
Начало » Python для новичков » парсер сайта
1
alextarnovskiy
написал вот такой код

 import requests
from bs4 import BeautifulSoup
def get_html(url):
    r = requests.get(url)
    return r.text
def get_all_links(html):
    soup = BeautifulSoup(html,'lxml')
    tds =soup.find('table', id='currencies-all').find_all('td',class_='currency-name')
    links= []
    for td in tds:
        a = td.find('a').get('href')
        links.append(a)
    return  links
def main():
    url ='https://coinmarketcap.com/all/views/all/'
    all_links = get_all_links(get_html(url))
    for i in all_links:
        print(i)
if __name__ =='__main__':
    main()

это первый парсер который я пробую сделать,ошибки вот такие

C:\Users\1\Desktop\bot2\venv\Scripts\python.exe CUsers/1/Desktop/bot/bot.py
Traceback (most recent call last):
File “CUsers/1/Desktop/bot/bot.py”, line 24, in <module>
main()
File “CUsers/1/Desktop/bot/bot.py”, line 20, in main
all_links = get_all_links(get_html(url))
File “CUsers/1/Desktop/bot/bot.py”, line 9, in get_all_links
soup = BeautifulSoup(html,'lxml')
File “C:\Users\1\Desktop\bot2\venv\lib\site-packages\bs4\__init__.py”, line 165, in __init__
% “,”.join(features))
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?

Process finished with exit code 1

подскажите как поправить? и в чем проблема
Romissevd
Код рабочий. Надо установить lxml.Вот тут посмотри
JOHN_16
alextarnovskiy
bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
ну как бы вам прямым текстом говорят что не так, но вы же наверняка даже не прочитали это, раз спрашиваете
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB