input: Write a function to create a web crawler in Python that starts from a given URL, looks for other links in the page, and scrapes the page content. If the URL is not valid, the function should return an empty list.
  
  def crawl(url):
      visited = set()
      queue = [url]
      scraped_data = []
  
      while queue:
          curr = queue.pop(0)
          if curr in visited:
              continue
          visited.add(curr)
          response = requests.get(curr)
  
          if response.ok:
              soup = BeautifulSoup(response.text, 'html.parser')
  
              # scrape the page here and append to scraped_data
              scraped_data.append(soup.get_text())
  
              # 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 scraped_data
  
  assert crawl('http://example.com') != []
  assert crawl('invalid-url') == []
output: 
  def crawl(url):
      visited = set()
      queue = [url]
      scraped_data = []
  
      while queue:
          curr = queue.pop(0)
          if curr in visited:
              continue
          visited.add(curr)
          try:
              response = requests.get(curr)
          except requests.exceptions.RequestException:
              return []
  
          if response.ok:
              soup = BeautifulSoup(response.text, 'html.parser')
  
              # scrape the page here and append to scraped_data
              scraped_data.append(soup.get_text())
  
              # 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 scraped_data
  