-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_html.py
33 lines (25 loc) · 1.07 KB
/
gen_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
32
# -*- coding: utf-8 -*-
from util import get_list
def generator(name):
with open(name + '.html', 'w') as f:
html_head = '''
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body >'''
html_end = '</body> </html>'
print('Generating HTML of ' + name.upper() + ' ...')
html_body = ''
for sid, title in get_list(name):
html_body += "<p align=center>" + sid + title + "\n"
html_body += "<a href='" + 'https://statementdog.com/analysis/tpe/' + sid + "'>財報狗</a>"
html_body += "<a href='" + 'http://www.wantgoo.com/stock/astock/index?StockNo=' + sid + "'> 玩股網</a></p>"
html_body += "<img src='" + 'pic/' + sid + '.png' + "' height='80%' width='100%' />\n"
html_text = html_head + html_body + html_end
f.write(html_text)
if __name__ == '__main__':
generator('tse')
generator('otc')
generator('my')
generator('watch')