input: Write a function that implements a web crawler in Python. The function should take a starting URL as input, look for other links on the page, and scrape the page content. Return the visited URLs and the content of each page.
  assert crawl('http://example.com')=={'http://example.com': 'Example Domain\nThis domain is for use in illustrative examples in documents. You may use this\ndomain in literature without prior coordination or asking for permission.\nMore information...\n'}
  assert crawl('http://sample.com')=={}
  assert crawl('http://nonexistent.com')=={}
output: def crawl(url):
      from urllib.request import urlopen
      from urllib.error import URLError
      from bs4 import BeautifulSoup
      import re
  
      visited_urls = {}
      try:
          response = urlopen(url)
          if response.getcode() == 200:
              html_content = response.read()
              soup = BeautifulSoup(html_content, 'html.parser')
              page_content = soup.get_text()
              visited_urls[url] = page_content.strip()
  
              links = soup.find_all('a', href=True)
              for link in links:
                  href = link['href']
                  if re.match(r'^http', href):
                      visited_urls.update(crawl(href))
      except URLError:
          pass
  
      return visited_urls