input: Write a function to scrape an online news website to get the headlines. The function should take a URL as input, retrieve the webpage content, parse it using BeautifulSoup, find all the headlines in 'h2' tags, and return the list of headlines as strings. If the URL is invalid or no headlines are found, the function should return an empty list.
  
  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.news.com/")==['Headline 1', 'Headline 2']
  assert scrape_headlines("https://www.invalidwebsite.com/")==[]
  assert scrape_headlines("https://www.news.com/job-board")==[]
  assert scrape_headlines("https://www.news.com/logout")==[]
  assert scrape_headlines("")==[]
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 []