input: Write a function to create a web scraper that extracts specific data from a given website. The function should utilize the Python package BeautifulSoup to parse webpages and extract the required data. BeautifulSoup will allow us to find HTML elements on the webpage using tags and attributes. Once the data is found, it can be converted into the desired format and stored.
  
  
  def extract_data_from_webpage(url, tag, attribute):
      import requests
      from bs4 import BeautifulSoup
  
      # Get the web page
      webpage = requests.get(url)
  
      # Parse the web page
      soup = BeautifulSoup(webpage.content, 'html.parser')
  
      # Find all elements with the specified tag
      elements = soup.find_all(tag)
  
      # Extract the data from the specified attribute
      data = [element.get(attribute) for element in elements]
      
      return data
  
  # Test cases
  assert extract_data_from_webpage("http://example.com", 'a', 'href') != []
  assert extract_data_from_webpage("http://example.com", 'img', 'src') != []
  assert extract_data_from_webpage("http://example.com", 'div', 'class') != []
  assert extract_data_from_webpage("http://invalidurl", 'a', 'href') == []
  assert extract_data_from_webpage("http://example.com", 'nonexistent_tag', 'href') == []
  
  
  The output of each test case should be a list of extracted data, or an empty list if no data is found or if an error occurs.
output: 
  def extract_data_from_webpage(url, tag, attribute):
      import requests
      from bs4 import BeautifulSoup
  
      try:
          webpage = requests.get(url)
          soup = BeautifulSoup(webpage.content, 'html.parser')
          elements = soup.find_all(tag)
          data = [element.get(attribute) for element in elements]
      except:
          data = []
      
      return data
  