import requests from bs4 import BeautifulSoup def check_li_tags(url): try: # Fetch the page response = requests.get(url) response.raise_for_status() # Raise an error for bad responses (4xx, 5xx) # Parse the HTML soup = BeautifulSoup(response.text, "lxml") # Find all
  • elements li_elements = soup.find_all("li") # Check if each
  • contains an tag for index, li in enumerate(li_elements): if not li.find("a"): print(f"Missing tag in
  • at index {index}: {li}") except requests.exceptions.RequestException as e: print(f"Error fetching the URL: {e}") # Prompt the user for a URL url = input("Enter the URL to check: ").strip() check_li_tags(url)