input: Write a function to scrape an online news website and extract all headlines from the given URL. Return a list of these headlines. If the URL is not accessible or no headlines are found, return an empty list.
  
  import requests
  from bs4 import BeautifulSoup 
  
  def scrape_headlines(url):
      try:
          r = requests.get(url) 
          soup = BeautifulSoup(r.content, 'html5lib') 
          headlines = soup.find_all('h2') 
          return [headline.text for headline in headlines]
      except:
          return []
  
  assert scrape_headlines("https://www.example.com/news")==[]
  assert scrape_headlines("https://www.news.com/")!=[]
output: def scrape_headlines(url):
      try:
          r = requests.get(url) 
          soup = BeautifulSoup(r.content, 'html5lib') 
          headlines = soup.find_all('h2') 
          return [headline.text for headline in headlines]
      except:
          return []