V
V
vikholodov2017-09-30 14:35:58
1C
vikholodov, 2017-09-30 14:35:58

Why doesn't the find_all method in BeautifulSoup want to work?

def get_freelance_list(html):
    soup = BeautifulSoup(html, "lxml")
    container = soup.find('table', class_='catalog-freelancers')
    frelancer = container.find_all('a', class_='freelancer-name').get('href')
    frelancer_link = 'https://www.fl.ru/' + frelancer
    return frelancer_link

Everything seems to be very simple, I found a table, look for all the links with that class in it, but nothing. If you put find instead of find_all, then it finds one link without any problems. What can be wrong?
Mistake
"ResultSet object has no attribute '%s'. You're probably treating a list of items like a single item. Did you call find_all() when you meant to call find()?" % key
AttributeError: ResultSet object has no attribute 'get'. You're probably treating a list of items like a single item. Did you call find_all() when you meant to call find()?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Kinash, 2019-06-20
@Dementor

Where can the layout "move out"? In the metadata tree of the configurator? So you added a new layout in front of it. What is the difference (other than aesthetic) in how layouts are arranged?
Or when you open a Word document, the content is not the same as it was in the original file, which was saved and thrown into the layout? After opening, you have a lot of changes to the document - by step-by-step commenting on the code, you can calculate which instruction causes the "moving out".
Regarding the binary layout. I recommend using the active document type: 1) so you won't need to save and overwrite binary data every time for changes - you can make all changes directly in the configurator; 2) when you receive the layout, immediately get a COM object ready to be populated and shown to users.

A
Andrey Myvrenik, 2017-09-30
@vikholodov

ResultSet object has no attribute 'get'. You're probably treating a list of items like a single item

The error message itself says it's wrong. You are calling a method geton an object that does not have that method. You are trying to get some href. Instead, you need to loop through the collection that returns find_alland from each element (tag) separately get the link from the attribute href. The normal findone works for you because it returns one element (tag).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question