匹配html标签中的任意标签内数据
-
匹配所有包含’oo’的单词
import re text = "JGood is a handsome boy, he is cool, clever, and so on..." re.findall(r'\w*oo\w*', text)
-
匹配 html中title里面的内容
原文:
import re
file = r'./202304.html'
f = open(file,'r',encoding='utf-8')
origin_content = f.read()
#r'<title>(.*)</title>' 效果一样
result = re.findall(r'<title>(.*?)</title>',origin_content)
print(result)
f.close()
打印内容: