Answer the question
In order to leave comments, you need to log in
How to parse a div with BeautifulSoup without IDs?
Good day. I decided yesterday to parse one of the sites in order to collect a database of clients with whom I can work and came across a problem: I can’t parse the div in which the phone is located because there are no identifiers.
For parsing, I use python 3 and the BeautifulSoup library. There were no problems with parsing the remaining fields. And here it doesn’t work at all, I already tried it using the css selector through nth-child (3).
Since I don’t have much experience in parsing yet, please guide me on the right path)
Answer the question
In order to leave comments, you need to log in
title = bs_obj.select('a.name_des.i')[0]
phone = title.find_next_sibling('div')
some_list = bs_obj.find('li', {'class': 'result_'})
phone = some_list.find_all('div')[1]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question