input: Write a function called scrape_headlines that scrapes an online news website to get the headlines. The function should accept a URL as an input and return a list of headlines gathered from the webpage. To achieve this, use the requests library to get the webpage, BeautifulSoup for parsing the web content, and extract the headlines from HTML tags typically used for headlines (e.g., 'h2').
  
  assert scrape_headlines("https://www.news.com/")==["Headline 1", "Headline 2"]
  assert scrape_headlines("https://www.anothernews.com/")==[]
  assert scrape_headlines("https://www.example.com/")==["Example Headline"]
  assert scrape_headlines("https://www.nonexistent.com/")==[]
output: def scrape_headlines(url):
      import requests
      from bs4 import BeautifulSoup
      try:
          response = requests.get(url)
          response.raise_for_status()
          soup = BeautifulSoup(response.text, 'html.parser')
          headlines = [headline.text for headline in soup.find_all('h2')]
          return headlines
      except:
          return []