-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathobj.py
More file actions
31 lines (24 loc) · 661 Bytes
/
obj.py
File metadata and controls
31 lines (24 loc) · 661 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
28
29
30
31
import bs4
import re
import util
import os
abspath = os.path.abspath(__file__)
dname = os.path.dirname(abspath)
os.chdir(dname)
out="out/Objetivos.html"
soup=util.get_soup("out/LFS201.html")
soup.title.string=soup.title.string+": Objetivos"
flds=soup.findAll("fieldset", attrs={'class': re.compile(r".*\bn2\b.*")})
for f in flds:
if f.legend.get_text().strip().lower()=="objetivos de aprendizaje":
f.legend.string=f.parent.h1.a.string
f.div.p.extract()
else:
f.extract()
for h in soup.findAll("h1"):
h.extract()
for div in soup.body.div.select(" > div"):
div.unwrap()
h=unicode(soup)
with open(out, "wb") as file:
file.write(h.encode('utf8'))