Answer the question
In order to leave comments, you need to log in
How to extract data by key from class variable 'bs4.element.resultset'?
after parsing the page
soup = BeautifulSoup(html.content, 'html.parser')
items = soup.find_all('form', {"id":"command"})
[{"title" : "холодильник", "price" : "100 руб" , "цвет" : "белый"} ,
{"title" : "стиральная машина", "price" : "200 руб" , "цвет" : "черный"},
{"title" : "миксер", "price" : "50 руб" , "цвет" : "красный"}]
холодильник
стиральная машина
миксер
Answer the question
In order to leave comments, you need to log in
It looks like a list of dictionaries, but if you check the len(items) methods, the result is 1. That is, there is only one element in the items variable.
you first have everything in the list (list, []), in which there is already a dict.
Try items[0] - the first element will be your dictionary.
This happened because the find_all method returns a list.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question