input: Write a function to create a web scraper that extracts specific data from a given website. The scraper should utilize the Python package BeautifulSoup to parse webpages and extract the required data using tags and attributes. If the data is found, it should be converted into the desired format and stored. If the website URL is invalid or inaccessible, return an error message indicating the failure.
  
  def web_scraper(url, tag, attribute):
      try:
          import requests
          from bs4 import BeautifulSoup
          webpage = requests.get(url)
          soup = BeautifulSoup(webpage.content, 'html.parser')
          elements = soup.find_all(tag)
          extracted_data = [element.get(attribute) for element in elements if element.get(attribute) is not None]
          return extracted_data
      except Exception as e:
          return str(e)
  
  assert web_scraper("https://example.com", 'a', 'href')==['https://example.com/page1', 'https://example.com/page2']
  assert web_scraper("https://invalidurl", 'div', 'class')=="Invalid URL 'https://invalidurl': No scheme supplied. Perhaps you meant http://https://invalidurl?"
  assert web_scraper("https://example.com", 'span', 'title')==['Example Title 1']
output: def web_scraper(url, tag, attribute):
      try:
          import requests
          from bs4 import BeautifulSoup
          webpage = requests.get(url)
          soup = BeautifulSoup(webpage.content, 'html.parser')
          elements = soup.find_all(tag)
          extracted_data = [element.get(attribute) for element in elements if element.get(attribute) is not None]
          return extracted_data
      except Exception as e:
          return str(e)