Я начал изучать python в этом году как новогодние решения, PI столкнулся с некоторыми проблемами при самообучении веб-скребков. Это могут быть глупые вопросы, но я надеюсь, что кто-то может указать на проблемы моих кодов. Заранее спасибо!
Хочу веб-скребок из Википедии Nobel Economi c Приз https://en.wikipedia.org/wiki/List_of_Nobel_Memorial_Prize_laureates_in_Economics
# I first get the whole table
wiki_table = soup.find('table',{'class':'wikitable'})
print(wiki_table)
# And grab the td information
name_list = wiki_table('td')
print(name_list)
type(name_list) #bs4.element.ResultSet
type(name_list[0:]) # list
# My goal is to separate laureate's name from other descriptions i.e. countries, years...What I plan to do is first get some lists containing people's names and then clean others unwanted strings.
# I tried to loop both the bs4 type and list type
laurates=[]
for a in name_list:
laurates.append(name_list.find_all(class='a'))
print(laurates)
# I looped for a here because the html is like `<a href="/wiki/Ragnar_Frisch" title="Ragnar Frisch">Ragnar Frisch</a>`. I thought the name is with the a code (or I interpreted wrongly?)