input: Write a function to create a web crawler in Python that starts from a given URL and recursively follows links on the page to scrape content. Use the `requests` and `BeautifulSoup` libraries to handle HTTP requests and parse HTML content, respectively. The function should return a list of unique URLs visited during the crawling process. If the initial URL is invalid or the request fails, the function should return an empty list.
  
  def crawl(url):
   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 
  
  # 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 list(visited)
  
  assert crawl('http://example.com')==['http://example.com']
  assert crawl('http://invalidurl.com')==[]
  assert crawl('http://singlepage.com')==['http://singlepage.com']
  assert crawl('http://loopback.com')==['http://loopback.com', 'http://loopback.com/link1']
  assert crawl('')==[]
output: def crawl(url):
      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 list(visited)