input: Write a function to scrape an online news website and retrieve all the headlines from the webpage. The function should take the URL of the website as input and return a list of headlines as strings. If the website cannot be accessed or the headlines are not found, the function should return an empty list.
  assert scrape_headlines("https://www.news.com/")==["First Headline", "Second Headline", "Third Headline"]
  assert scrape_headlines("https://www.notanews.com/")==[]
  assert scrape_headlines("https://www.unreachablewebsite.com/")==[]
  assert scrape_headlines("https://www.news.com/pagewithouth2")==[]
  assert scrape_headlines("")==[]
output: import requests
  from bs4 import BeautifulSoup
  
  def scrape_headlines(url):
      try:
          response = requests.get(url)
          response.raise_for_status()
          soup = BeautifulSoup(response.text, 'html.parser')
          headlines = [h2.text for h2 in soup.find_all('h2')]
          return headlines
      except:
          return []