I have this method in a class
class CatList:
lista = codecs.open(\'googlecat.txt\', \'r\', encoding=\'utf-8\').read()
soup = BeautifulSoup(lista)
You forgot the self
argument.
You need to change this line:
def parseList(tag):
with:
def parseList(self, tag):
You also got a global name error, since you're trying to access parseList
without self
.
While you should to do something like:
self.parseList(item)
inside your method.
To be specific, you need to do that in two lines of your code:
return [self.parseList(item)
and
return (tag.contents[0].string.strip(), self.parseList(tag.ul))