I'm trying to iterate over all directories in directory and find all .html files there. So far I've this code:
def find_path():
"""
:return: List
"""
paths = []
for filename in os.listdir(DIRECTORY):
    if filename.endswith('.html'):
        fname = os.path.join(DIRECTORY, filename)
        with open(fname, 'r') as f:
            soup = BeautifulSoup(f.read(), 'html.parser')
            path = soup.select_one('#tree > li > span').contents[-1]
            paths.append(path)
return paths
But it only works if all .html files are in one directory. What I need is to iterate over all .html files in this directory and save it, but for every directory in that directory there are also .html files that I need to have access to. So ideally, I need to open all of these directories in my parent directory and save whatever I need from .html files. Is there a way to do it?
Thanks!
 
     
     
    