Skip to content

Commit ee15ab8

Browse files
add exercise0008
1 parent 8751549 commit ee15ab8

File tree

2 files changed

+599
-0
lines changed

2 files changed

+599
-0
lines changed

exercise0008/html_parse.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# coding: utf-8
2+
# author: jessun
3+
# date: 2017/6/15 15:59
4+
# **第 0008 题:**一个HTML文件,找出里面的**正文**。
5+
import re
6+
7+
8+
def html_parse(input_file):
9+
with open(input_file, 'rt', encoding='utf-8') as f:
10+
html_content = f.read()
11+
12+
html_body = re.search(r'<body>(.*)</body>', html_content, re.S)
13+
print(input_file+'的正文内容为')
14+
print(html_body.group(1))
15+
16+
17+
if __name__ == '__main__':
18+
html_parse("index.html")

0 commit comments

Comments
 (0)