import urllib.request import re url = "http://140.44.4.36:5380/" with urllib.request.urlopen(url, timeout=5) as resp: html = resp.read().decode('utf-8') # Search for login modal or sso in html lines = html.splitlines() for i, line in enumerate(lines): if 'modalLogin' in line or 'btnSSO' in line or 'btnModalLogin' in line or 'Single Sign-On' in line or 'sso' in line.lower(): start = max(0, i-5) end = min(len(lines), i+15) print(f"--- Around line {i} ---") for j in range(start, end): print(f"{j:4}: {lines[j]}") print()