-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_nav.py
More file actions
27 lines (22 loc) · 864 Bytes
/
check_nav.py
File metadata and controls
27 lines (22 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import glob
from bs4 import BeautifulSoup
broken = []
for file in glob.glob('posts/*.html'):
with open(file, 'r', encoding='utf-8') as f:
soup = BeautifulSoup(f.read(), 'html.parser')
header = soup.find('header', class_='glass-header')
if not header:
print(f'{file} is missing <header class="glass-header">')
broken.append(file)
continue
nav = header.find('nav', class_='container')
if not nav:
print(f'{file} is missing <nav class="container"> inside header')
broken.append(file)
continue
# Check if nav links exist
nav_links = nav.find('ul', id='nav-links', class_='nav-links')
if not nav_links:
print(f'{file} is missing <ul id="nav-links" class="nav-links">')
broken.append(file)
print(f"Total broken navigation pages: {len(broken)}")