parsing [re]
언어/python2017. 12. 18. 21:34
import re
s = """<html><head>"Hello world"</head><body><p>paragraph</p></body></html>"""
while (1):
if s != None:
s_indx = re.compile("[<]+")
e_indx = re.compile("[>]+")
# if s_indx == None or e_indx == None:
# break
f1 = s_indx.search(s)
f2 = e_indx.search(s)
try:
f1.span()
f2.span()
except:
break
else:
print(s[f1.span()[1]:f2.span()[0]])
s = s[f2.span()[1]:]
else:
break
'언어 > python' 카테고리의 다른 글
openpyxl + numpy + matplotlib (0) | 2017.12.26 |
---|---|
python matplotlib 증가하는 지수함수 그래프 (0) | 2017.12.26 |
python + html (갓 파이썬 !!!!!!!) (0) | 2017.12.17 |
capche (0) | 2017.12.13 |
크롤링 (0) | 2017.11.26 |