with open('/home/x79/sisvietnamvn_01/BV_DHYD_HCM/Đội ngũ bác sĩ UMC.html', 'r', encoding='utf-8') as f: text = f.read() import re if "Khoa Da liễu" in text: print("Found 'Khoa Da liễu'!") matches = re.finditer(r'.{0,50}Khoa Da liễu.{0,50}', text) for m in matches: print("Context:", m.group(0)) else: print("Not found 'Khoa Da liễu'")