with open('app/modules/sag/templates/detail.html', 'r', encoding='utf-8') as f: html = f.read() import re for match in re.finditer(r']*data-module="([^"]+)"', html): print(match.group(1))