input: Write a function to create a web scraper that extracts specific data from a given website using the Python package BeautifulSoup. The function should parse webpages, find HTML elements using tags and attributes, and then convert the extracted data into the desired format for storage.
  assert extract_data("https://example.com")==["data1", "data2", "data3"]
  assert extract_data("https://samplewebsite.com")==["sample_data1", "sample_data2"]
  assert extract_data("https://nonexistentwebsite.com")==[]
  assert extract_data("https://unscrapablewebsite.com")==[]
  assert extract_data("")==[]
output: def extract_data(url):
      try:
          import requests
          from bs4 import BeautifulSoup
          response = requests.get(url)
          if response.status_code != 200:
              return []
          soup = BeautifulSoup(response.content, 'html.parser')
          data = []
          for tag in soup.find_all('div', class_='data'):
              data.append(tag.text)
          return data
      except:
          return []