-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathedit_html.py
31 lines (28 loc) · 1.17 KB
/
edit_html.py
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
from bs4 import BeautifulSoup
# meta.decompose()
def processHTML(htmlpath):
f = open(htmlpath, "r", encoding="utf8")
contents = [line.rstrip('\n') for line in f]
f.close()
# contents.insert(10, '<link rel="stylesheet" type="text/css" href="/assets/style.css">')
# contents.insert(11, '<script async type="text/javascript" src="/assets/webgazer.js"></script>')
inject = open('inject.html', 'r', encoding="utf8")
contents_inject= inject.readlines()
contents.insert(20, "".join(contents_inject))
f= open(htmlpath, "w", encoding="utf8")
contents= "".join(contents)
f.write(contents)
f.close()
# def processHTML(htmlpath):
# f = open(htmlpath, "r", encoding="utf8")
# contents = [line.rstrip('\n') for line in f]
# f.close()
# # contents.insert(10, '<link rel="stylesheet" type="text/css" href="/assets/style.css">')
# # contents.insert(11, '<script async type="text/javascript" src="/assets/webgazer.js"></script>')
# inject = open('inject.html', 'r', encoding="utf8")
# contents_inject= inject.readlines()
# contents.insert(20, "".join(contents_inject))
# f= open('test.html', "w", encoding="utf8")
# contents= "".join(contents)
# f.write(contents)
# f.close()