input: from typing import Set
  from bs4 import BeautifulSoup
  import requests
  import re
  
  def crawl(url: str) -> Set[str]:
      """Starts from a given URL and crawls through all linked pages, collecting the URLs visited.
      The crawler uses BFS (Breadth-First Search) to visit each page and collects all unique links found.
      
      >>> crawl("http://example.com")
      {'http://example.com', 'http://example.com/page1', 'http://example.com/page2'}
      """
      visited = set()
      queue = [url]
      
      while queue:
          curr = queue.pop(0)
          visited.add(curr)
          response = requests.get(curr)
          
          if response.ok:
              soup = BeautifulSoup(response.text, 'html.parser')
              
              # Scrape the page here if needed
              
              # Find all the links
              links = soup.find_all('a', href=re.compile('^http'))
              
              for link in links:
                  if link['href'] not in visited:
                      queue.append(link['href'])
      
      return visited
output:     visited = set()
      queue = [url]
      
      while queue:
          curr = queue.pop(0)
          if curr in visited:
              continue
          visited.add(curr)
          try:
              response = requests.get(curr)
              if response.ok:
                  soup = BeautifulSoup(response.text, 'html.parser')
                  links = soup.find_all('a', href=re.compile('^http'))
                  for link in links:
                      if link['href'] not in visited:
                          queue.append(link['href'])
          except requests.RequestException:
              continue
      
      return visited