I need to parse some information about writers with BeautifulSoup from wikidata.
Page: https://www.wikidata.org/wiki/Q39829
Problem
I need to parse the field "child" from the page. In the result I want to get 3 names. But instead of 3 names, I got 3 names + 2 extra values.
Code
children_html = soup.find('div', id='P40').find_all('div', class_='wikibase-snakview-variation-valuesnak')
children_list = [child.text.strip() for child in children_html]
print(children_list)
The result is:
['Joe Hill', 'Owen King', 'Naomi King', 'https://books.google.de/books?id=aPBbAgAAQBAJ', '81']
Question
Is there any way to get only name in the result:
['Joe Hill', 'Owen King', 'Naomi King']
The code should also work for other writers pages. Who could have less or more children