I have this method in the class
class CatList: lista = codecs.open('googlecat.txt', 'r', encoding='utf-8').read() soup = BeautifulSoup(lista) # parse the list through BeautifulSoup def parseList(tag): if tag.name == 'ul': return [parseList(item) for item in tag.findAll('li', recursive=False)] elif tag.name == 'li': if tag.ul is None: return tag.text else: return (tag.contents[0].string.strip(), parseList(tag.ul))
but when I try to call it like this:
myCL = CatList() myList = myCL.parseList(myCL.soup.ul)
I have the following error:
parseList() takes exactly 1 argument (2 given)
I tried to add myself as an argument to the method, but when I do this, I get the following:
global name 'parseList' is not defined
itβs not entirely clear how this works.
Any clues?
thanks
lorussian
source share