input: Write a function that creates a web scraper to extract specific data from a given website using the BeautifulSoup Python package. The web scraper should be capable of parsing webpages, finding HTML elements using tags and attributes, and converting the extracted data into the desired format for storage. The function should return the extracted data in the format specified by the user.
  
  assert create_web_scraper("<url_of_webpage>", "a", "href") == ["<url1>", "<url2>", "<url3>"]
  assert create_web_scraper("<url_of_webpage>", "img", "src") == ["<image_url1>", "<image_url2>"]
  assert create_web_scraper("<url_of_webpage>", "p", None) == ["<paragraph1>", "<paragraph2>"]
  assert create_web_scraper("<invalid_url>", "a", "href") == []
output: def create_web_scraper(url, tag, attribute=None):
      try:
          import requests
          from bs4 import BeautifulSoup
          response = requests.get(url)
          soup = BeautifulSoup(response.text, 'html.parser')
          elements = soup.find_all(tag)
          if attribute:
              return [element.get(attribute) for element in elements if element.get(attribute)]
          else:
              return [element.text.strip() for element in elements]
      except:
          return []