Skip to content

Instantly share code, notes, and snippets.

@LukasWoodtli
Created April 7, 2022 13:16
Show Gist options
  • Save LukasWoodtli/1851cf2e4de80b60df7ae36882bb1577 to your computer and use it in GitHub Desktop.
Save LukasWoodtli/1851cf2e4de80b60df7ae36882bb1577 to your computer and use it in GitHub Desktop.
from bs4 import BeautifulSoup
with open(r'MyBool Packt.htm') as in_file:
soup = BeautifulSoup(in_file, 'html.parser')
toc = soup.find_all('ol', id="accordion-toc")
entry = soup.find_all('a', class_='toc-index')
for e in entry:
print(e.text.strip())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment